String prompt1 enter an account number or 999 to exit

This preview shows page 18 - 24 out of 37 pages.

string PROMPT1 = “Enter an account number or 999 to exit” string PROMPT2 = “Enter the first name, last name, and balance” housekeeping while accountNum does not equal 999 detailLoop() endwhile finishUp() stop housekeeping() output PROMPT1
Programming Logic and Design, 6e Solutions 5-19 input accountNum return detailLoop() output PROMPT2 input firstName, lastName, balance output accountNum, firstName, lastName year = 0 while year < TERM balance = balance * (1 + INTEREST_RATE) year = year + 1 output year, balance endwhile output PROMPT1 input accountNum return finishUp() output “End of program” return 10. Mr. Roper owns 20 apartment buildings. Each building contains 15 units that he rents for $800 per month each. Design the application that would print 12 payment coupons for each of the 15 apartments in each of the 20 buildings. Each coupon should contain the building number (1 through 20), the apartment number (1 through 15), the month (1 through 12), and the amount of rent due.
Programming Logic and Design, 6e Solutions 5-20 Pseudocode: start Declarations num buildingNum num aptNum num month num TOTAL_BUILDS = 20 num TOTAL_UNITS = 15 num TOTAL_MONTHS = 12 num RENT = 800 string COUPON_HEADING = “Payment Coupon” housekeeping() while buildingNum <= TOTAL_BUILDS
Programming Logic and Design, 6e Solutions 5-21 detailLoop() endwhile finishUp() stop housekeeping() buildingNum = 1 return detailLoop() aptNum = 1 while aptNum <= TOTAL_UNITS month = 1 while month <= TOTAL_MONTHS output COUPON_HEADING output “Building Number: “, buildingNum output “Apartment Number: “, aptNum output “Month: “, month output “Rent Due: “, RENT month = month + 1 endwhile aptNum = aptNum + 1 endwhile buildingNum = buildingNum + 1 return finishUp() output “End of program” return 11. a. Design a program for the Hollywood Movie Rating Guide, in which users continuously enter a value from 0 to 4 that indicates the number of stars they are awarding to the Guide’s featured movie of the week. The program executes continuously until a user enters a negative number to quit. If a user enters a star value that does not fall in the correct range, reprompt the user continuously until a correct value is entered. At the end of the program, display the average star rating for the movie.
Programming Logic and Design, 6e Solutions 5-22 Pseudocode: start Declarations num numOfStars num count = 0 num total = 0 num avg string PROMPT = “Enter the star rating or a negative number to quit” housekeeping() while numOfStars >= 0 detailLoop() endwhile finishUp() stop housekeeping() output PROMPT input numOfStars return
Programming Logic and Design, 6e Solutions 5-23 detailLoop() while numOfStars > 4 OR numOfStars < 0 output “Please enter a value from 0 to 4” input numOfStars endwhile count = count + 1 total = total + numOfStars output PROMPT input numOfStars return finishUp() avg = total / count output “The average star rating is: ”, avg output “End of program” return

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture