Displayusdatemonth day year else if choice uk then

• Homework Help
• 390
• 91% (22) 20 out of 22 people found this document helpful

This preview shows page 19 - 25 out of 390 pages.

displayUSDate(month, day, year) else if choice = “UK” then displayUKDate(month, day, year) else displayISDate(month, day, year) endif endif return Flowchart: Pseudocode: start Declarations num numDays num rate string isMealIncld string mealCode output “Enter the number of days in the stay ” input numDays output “Will meals be included? (Y/N) ” input isMealIncld if isMealIncld = “Y” then output “Enter the meal plan code (A or C) ” input mealCode rate = computeRate(numDays, mealCode) else 11. Create the logic for a program that computes hotel guest rates at Cornwall’s Country Inn. In Answer: A sample solution follows
rate = computeRate(numDays) endif output “The rate is: ”, rate stop num computeRate(num days) Declarations num rate rate = days * 99.99 return rate num computeRate(num days, string code) Declarations num rate num price if code = “A” then price = 169 else if code = “C” then price = 112 else price = 0 output “Invalid meal plan code entered” endif endif rate = days * price return rate Flowchart: Pseudocode: start Declarations num x num LENGTH = 5 num numbers[LENGTH] x = 0 while x < LENGTH 12. Create the logic for a program that prompts a user for 10 numbers and stores them in an arra Answer: A sample solution follows
output “Enter a number” input numbers[x] x = x + 1 endwhile reverseNumbers(numbers, LENGTH) x = 0 while x < LENGTH output numbers[x] x = x + 1 endwhile stop void reverseNumbers(num[] vals, num size) Declarations num x num lastIndex num temp lastIndex = size – 1 x = 0 while (lastIndex – x) > x temp = vals[lastIndex – x] vals[lastIndex – x] = vals[x] vals[x] = temp x = x + 1 endwhile return Flowchart: Pseudocode: start Declarations num x num average string doContinue num LENGTH = 6 num numbers[LENGTH] doContinue = “Y” while doContinue = “Y” 13. Create the logic for a program that prompts a user for six numbers and stores them in an arra Answer: A sample solution follows
x = 0 while x < LENGTH output “Enter a number” input numbers[x] x = x + 1 endwhile average = calcAverage(numbers, LENGTH) x = 0 while x < LENGTH output numbers[x], average – numbers[x] x = x + 1 endwhile output “Would you like to continue (Y/N)?” input doContinue endwhile stop num calcAverage(num[] vals, num size) Declarations num x num avg num sum sum = 0 x = 0 while x < size sum = sum + vals[x] x = x + 1 endwhile avg = sum / size return avg 14. The Information Services Department at the Springfield Library has created methods with th Signatur e Descript ion
num getNumb er(num high, num low) Prompts the user for a number, and continues to prompt until the number falls between designate d high and low limits; returns a valid number string getChar acter() Prompts the user for a character string and returns the entered string num lookUpI SBN(str ing title) Accepts the title of a book and returns the ISBN; returns a 0 if the book cannot be found
a. Design an interactive program that does the following, using the prewritten methods wherever th Pseudocode: char lookUpT itle(nu m isbn) Accepts the ISBN of a book and returns a title; returns a space character if the book cannot be found