95%(19)18 out of 19 people found this document helpful
This preview shows page 22 - 27 out of 396 pages.
16. The Café Noir Coffee Shop wants some market research on its customers. When a customer
output “Please re-enter the number of items >> ”input numItemsattempts = attempts + 1endwhileif attempts = 2 AND numItems < 0 thenoutput “An invalid number of items was entered”output “This order will not be counted”validNumItems = 0endifreturn housekeeping()output ZIP_PROMPTinput custZipreturndetailLoop()output AGE_PROMPTinput custAgeoutput ITEM_PROMPTinput numItemsvalidateZipCode()validateCustAge()validateNumItems()if validNumItems = 1 thencountOfOrders = countOfOrders + 1totalCustAge = totalCustAge + custAgeif custZip = STORE_ZIPnumItemsInStoreZip = numItemsInStoreZip + numItemselsenumItemsInOtherZips = numItemsInOtherZips + numItemsendifif custAge < 30 thennumItemsUnder30 = numItemsUnder30 + numItemselsenumItems30AndOlder = numItems30AndOlder + numItemsendifendifoutput ZIP_PROMPTinput custZipreturnfinishUp()
DeclarationsavgCustAgeif countOfOrders > 0 thenoutput “Total items ordered in the ”, STORE_ZIP, “ zip code = ”, numItemsInStoreZipoutput “Total items ordered in other zip codes = ”, numItemsInOtherZipsavgCustAge = totalCustAge / countOfOrdersoutput “The average customer age is: ”, avgCustAgeoutput numItemsUnder30, “ items were ordered by customers under 30”output numItems30AndOlder,“ items were ordered by customers 30 and older”endifoutput “End of program”returnPerforming Maintenance// The QuickCopy company currently makes 60,000 copies per year// at 15 cents each.// They expect to increase the number of copies produced// by 4 percent per year each year for the next 10 years,// starting with this year.// They also expect the price of each copy to increase// by 3 cents per year, starting with this year.// This program displays the company's expected// income for each of the next 10 years.// Modify it to be more efficient.startDeclarationsnum year = 1num copies = 60000num price = 0.15num total = 0num COPIES_INCREASE = 0.04num PRICE_INCREASE = 0.03num YEARS = 10while year <= YEARSFlowchart:The flowchart’s structure will be very similar to that given for previous exercises.1.A file named MAINTENANCE05-01.txt is included with your downloadable student files. AAnswer: