# Ch05_Logic6e_Solutions - Programming Logic and Design 6e...

• Homework Help
• 37
• 96% (167) 161 out of 167 people found this document helpful

This preview shows page 1 - 9 out of 37 pages.

Programming Logic and Design, 6eSolutions 5-1Programming Logic and Design, 6th EditionChapter 5Exercises1.What is output by each of the pseudocode segments in Figure 5-22?Answer: a.5, 22, 5b.4, 6, 7c.5, 6
2.Design the logic for a program that outputs every number from 1 through 10.
Programming Logic and Design, 6eSolutions 5-2Pseudocode:startDeclarationsnum numberhousekeeping()number = 1while number <= 10detailLoop()endwhilefinishUp()stophousekeeping()number = 1returndetailLoop()output numbernumber = number + 1returnfinishUp()output “End of program”return
Programming Logic and Design, 6eSolutions 5-33.Design the logic for a program that outputs every number from 1 through 10 along with its square and cube.
Programming Logic and Design, 6e
4.Design the logic for a program that outputs every even number from 2 through 30.
Programming Logic and Design, 6eSolutions 5-5Pseudocode:startDeclarationsnum numberhousekeeping()while number <= 30detailLoop()endwhilefinishUp()stophousekeeping()number = 2returndetailLoop()output numbernumber = number + 2returnfinishUp()output “End of program”
Programming Logic and Design, 6eSolutions 5-6return5.Design the logic for a program that outputs numbers in reverse order from 10 down to 1.
Programming Logic and Design, 6e
6.a. The No Interest Credit Company provides zero-interest loans to customers. Design an application that gets customer account data, including an account number, customer name, and balance due. Output the account number and name; then output the customer’s projected balance each month for the next 10 months. Assume that there is no finance charge on this account, that the customer makes no new purchases,and that the customer pays off the balance with equal monthly payments, which are 10 percent of the original bill.
Programming Logic and Design, 6eSolutions 5-8Pseudocode:startDeclarationsnum accountNumnum balanceDuenum monthnum paymentAmtstring custNamenum PAY_RATE = 0.10string PROMPT1 = “Enter an account number”string PROMPT2 = “Enter the customer name and balance due”housekeeping()detail()finishUp()stophousekeeping()output PROMPT1