Question: Shopping spree exercise using arrays: Write a program that lets the user spend up to $1,000 dollars or 5 items, whichever comes first, one item
Shopping spree exercise using arrays:
Write a program that lets the user "spend" up to $1,000 dollars or 5 items, whichever comes first, one item at a time. Do not allow the user to spend more than $1,000 dollars. Do not allow the user to purchase more than 5 items.
Step 1: Prompt for the price of each item. Store each item price in the array named prices. When the user has reached $1,000 or 5 items, print out how much was spent, how many items were bought, how much is left, and the average price. Print a table of the prices of the items bought.
Step 2: Expand your program to include item names. Prompt for each item name right before each price. Use another array to store the item names. (Hint: it's an array of strings. Look at the file attached here, pgm7-1string.cpp. Note that cin will only input one word.) Print a table of items bought, with the name and price of each one.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
