The Caf\u00e9 Noir Coffee Shop wants some market research on its customers When a

The café noir coffee shop wants some market research

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 numItems attempts = attempts + 1 endwhile if attempts = 2 AND numItems < 0 then output “An invalid number of items was entered” output “This order will not be counted” validNumItems = 0 endif return housekeeping() output ZIP_PROMPT input custZip return detailLoop() output AGE_PROMPT input custAge output ITEM_PROMPT input numItems validateZipCode() validateCustAge() validateNumItems() if validNumItems = 1 then countOfOrders = countOfOrders + 1 totalCustAge = totalCustAge + custAge if custZip = STORE_ZIP numItemsInStoreZip = numItemsInStoreZip + numItems else numItemsInOtherZips = numItemsInOtherZips + numItems endif if custAge < 30 then numItemsUnder30 = numItemsUnder30 + numItems else numItems30AndOlder = numItems30AndOlder + numItems endif endif output ZIP_PROMPT input custZip return finishUp()
Declarations avgCustAge if countOfOrders > 0 then output “Total items ordered in the ”, STORE_ZIP, “ zip code = ”, numItemsInStoreZip output “Total items ordered in other zip codes = ”, numItemsInOtherZips avgCustAge = totalCustAge / countOfOrders output “The average customer age is: ”, avgCustAge output numItemsUnder30, “ items were ordered by customers under 30” output numItems30AndOlder, “ items were ordered by customers 30 and older” endif output “End of program” return Performing 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. start Declarations num year = 1 num copies = 60000 num price = 0.15 num total = 0 num COPIES_INCREASE = 0.04 num PRICE_INCREASE = 0.03 num YEARS = 10 while year <= YEARS Flowchart: 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. A Answer :

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture