Question: please carefully follow the derection ( very important ) A32. (25 pts) You must use a do while loon in the following program: following: This
A32. (25 pts) You must use a do while loon in the following program: following: This program will ask the user for items to buy and their quantities, and write a shopping Write, compile, debug. and run a program that will use the specified loops to do the list to a file. The program does all of the following during one run: . Open a file named "shopping.txt for write access Use a do while loop to get the items from the user and write them to the file: o Prompt the user for an item to place on the shopping list (i.e.apples). . o Prompt for the quantity of that item, using the name of the item in the .For example, if the user entered "apples", prompt "How o Write each item and its quantity to the file, item first, quantity second prompt many apples? (don't worry about grammar and plurals.) (Le. apples 5) with only spaces between each write, nothing else (no punctuation, no endl, no In) o Ask the user if they want to keep entering items o Loop until the user enters N or n to this question (loop should only end if they enter N or n.) (This is the do while loop condition.) Close the file Open the same file for read access Use a while loop to read the file and display Read each item and quantity from the file, individually, into separate variables Display the shopping list to the screen, with each quantity and item on a new line (after a heading line) Read individual item and quantity values from the file using the >> operator. Do not read whole lines. Do not use any other method to read from the file (i.e. don't use getline, rdbuf, or any way other than what is used in your textbook chapter 5.) The while loop should read until it reaches the end of the file. (it should not loop a certain number of times-don't count how many writes the earlier loop did and then do the same number of reads.) o o o o .Close the file Your output should look similar to this: Here is your shopping list for today: 5 apples 1 bread 2 milk Code Header input/output Required. Show the complete input and expected output of one example using 3 items
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
