# Dueyear 2018 and duemonth 6 and dueday 1 then

• 84
• 100% (5) 5 out of 5 people found this document helpful

This preview shows page 49 - 56 out of 84 pages.

h. A program that continuously accepts policy holders’ data and displays the data for anyone who has a policy number between 1000 and 4000 inclusive, whose policy comes due in September or October of any year, and who has had three or fewer accidents.
Programming Logic and Design, 9eSolutions 4-50Pseudocode:startDeclarationsnum policyNumbernum agenum dueMonthnum dueDaynum dueYearnum accidentsstring lastNamestring firstNamehousekeeping()while not eofdetailLoop()endwhilefinish()stophousekeeping()output “Insurance program”
Programming Logic and Design, 9eSolutions 4-51input policyNumber, lastName, firstName, age, dueMonth, dueDay, dueYear, accidentsreturndetailLoop()if (policyNumber >= 1000 AND policyNumber <= 4000) AND(dueMonth = 9 OR dueMonth = 10) AND accidents <= 3 thenvalidateData()output policyNumber, lastName, firstName, age, dueMonth, dueDay, dueYear, accidentsendifinput policyNumber, lastName, firstName, age, dueMonth, dueDay, dueYear, accidentsreturnfinish()output “End of program”return8.The Barking Lot is a dog day care center. Design a flowchart or pseudocode for following:a. A program that accepts data for an ID number of a dog’s owner, and the name, breed, age, and weight of the dog. Display a bill containing all the input data as well as the weekly day care fee, which is \$55 for dogs under 15 pounds, \$75 for dogs from15 to 30 pounds inclusive, \$105 for dogs from 31 to 80 pounds inclusive, and \$125 for dogs over 80 pounds.Answer: A sample solution is as follows:Flowchart:
Programming Logic and Design, 9eSolutions 4-52Pseudocode:startDeclarationsnum idNumbernum dogAgenum dogWeightnum feestring dogNamestring dogBreednum SMALL_FEE = 55num MED_FEE = 75num LARGE_FEE = 105num XLARGE_FEE = 125housekeeping()detail()finish()stophousekeeping()
Programming Logic and Design, 9eSolutions 4-53output “Dog Day Care”input idNumber, dogName, dogBreed, dogAge, dogWeightreturndetail()if dogWeight < 15 thenfee = SMALL_FEEelseif dogWeight <= 30 thenfee = MED_FEEelseif dogWeight <= 80 thenfee = LARGE_FEEelsefee = XLARGE_FEEendifendifendifoutput idNumber, dogName, dogBreed, dogAge, dogWeight, feereturnfinish()output “End of program”returnb. A program that continuously accepts dogs’ data until a sentinel value is entered, and displays billing data for each dog.Answer: A sample solution is as follows:Flowchart:
Programming Logic and Design, 9eSolutions 4-54Pseudocode:startDeclarationsnum idNumbernum dogAgenum dogWeightnum feestring dogNamestring dogBreednum SMALL_FEE = 55num MED_FEE = 75num LARGE_FEE = 105num XLARGE_FEE = 125num QUIT = 9999string PROMPT = “Enter an ID number or 9999 to quit >> ”
Programming Logic and Design, 9eSolutions 4-55housekeeping()