The cafe noir coffee shop wants some market research on its customers. When a cu
ID: 3639926 • Letter: T
Question
The cafe noir coffee shop wants some market research on its customers.
When a customer places an order, a clerk asks for the customer's zip code and age. The clerk enters that data as well as the number of items the customer order. The program operates continously until the clerk enters a 0 for zip code at the end of the day. When the clerk enters an invalid zip code (more than 5 digits) or an invalid age (defined as less than 10 or more than 110), the program repormpts the clerk continously. When the clerk enters fewr than 1 or more than 12 items, the program reprompts the clerk two more times. If the clerk enters a high value on the tird attempt, the program accepts the high value, but if the clerk enters a negative value on the third attempt, an error message is displayed and the order is not counted. At the end of the program, display a count of the number of items ordered by customers from the same zip code as the coffee shop (54984) and a count from other zip codes. Also display the average customer age, as well as counts of the number of items order by customers under 30 and by customers 30 and older.
Explanation / Answer
PS: Please rate the answer start Declarations num custZip num custAge num numItems = 0 num validNumItems num countOfOrders = 0 num totalCustAge = 0 num numItemsUnder30 = 0 num numItems30AndOlder = 0 num numItemsInStoreZip = 0 num numItemsInOtherZips = 0 num STORE_ZIP = 54984 string ZIP_PROMPT = “Enter the zip code” string AGE_PROMPT = “Enter the customer’s age” string ITEM_PROMPT = “Enter the number of items” housekeeping() while custZip not equal to 0 detailLoop() endwhile finishUp() stop validateZipCode() while custZip > 99999 output “Please enter a valid zip code” input custZip endwhile return validateCustAge() while custAge < 10 OR custAge > 110 output “Please enter a valid customer age” input custAge endwhile return validateNumItems() Declarations num attempts = 0 num LIMIT = 2 validNumItems = 1 while (numItems < 1 OR numItems > 12) AND attempts 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” returnRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.