Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Programming Exercise #1 - File 1/0 (8 pts) The file A3Q1_shoppingList.txt (included in downloaded handout) contain a list of items and name under different categories.
Programming Exercise #1 - File 1/0 (8 pts) The file A3Q1_shoppingList.txt (included in downloaded handout) contain a list of items and name under different categories. Write a program to that allows the user to input a category name (fruit, meat, dairy and vegetable) from the keyboard. The program should then read from the file and search for matching items under the required category and write into a file (output.txt) with the item(s) name, sub-total price of current category and the total price of the whole shopping list. The program should also indicate if there is no match (see Figure3). Your program also must account for the following scenarios: Your program cannot open the data file. Figure1 illustrates the expected behavior. Your program should write all the item(s) information found into the file output.txt. Your program should be able to read the file in order to write the complete item(s) information. Please note your program must use the same file name (A3Q1_shoppingList.txt and output.txt) to read and write the files. Figure 2 & 3 illustrate the expected behaviors. Here are a few sample outputs to illustrate the expected behavior of your program. Note: user input is highlighted with a red circle. Shopping List Finder Sorry! Could not open the file A3Q1_shoppingList.txt. Program ending ... Figure 1. Sample output when can't open file I Shopping List Finder 1 Please enter the category name to check: fruit Search is done! Please check the results in the output file. Thank you for using our shopping program!! output.txt There are 2 item(s) found under the category fruit. Here is the list: apple banana The subtotal price is $20.92 The total price of the whole shopping list is $97.43. Figure 2. Sample Output Examplel *** | Shopping List Finder 1 Please enter the category name to check: (dessert Search is done! Please check the results in the output file. Thank you for using our shopping program!! output.txt No item is found from the category dessert. The total price of the whole shopping list is $97.43. Figure 3. Sample Output Example2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started