Question: In this program you will create a C++ program to store items in shopping cart, in order to get as many items as possible without

In this program you will create a C++ program to store items in shopping cart, in order to get as many items as possible without exceeding a given budget USING LINKED LIST Each item information include: Product name Cost Input and Output The input is a single text file. Each file starts with a single number (budget), followed by a list of items and their cost. Example of input 15.00 Apples, 1.50 Broccoli, 2.00 Yogurt, 4.00 Chocolate, 3.80 Paper towels, 2.20 Milk, 1.70 Ice cream, 4.50 The total of the list above is 19.70, which is more than the allowed budget. The strategy used in this homework will be to remove the most expensive item until we are below the required budget again. In this case, we will remove first "Ice cream, then Yogurt. Note that this strategy will maximize the number of items, but not necessarily the budget. If two or more items have the same maximum price, remove the last in alphabetical order. As output, we will print the final list sorted by product name, and the total number of items and cost. Example of output Apples, 1.50 Broccoli, 2.00 Chocolate, 3.80 Milk, 1.70 Paper towels, 2.20 Number of items: 5 Cost: 11.20 The main C++ program will become the executable to be tested by the TAs. The result should be written on another text file (output file), provided on the command line. The input and output files are specified in the command line, not inside the C++ code. The general call to the executable (max_items, in this example) is as follows: max_items "A=;C=" Call example with one input file and another output file. max_items "A=a.txt;C=c.out" Handling wrong input Your program should execute some basic checks on the input file to verify that all information is valid. Examples of not valid input files include: A file that does not include a budget Negative budget or costs Items with no names If the file does not include a budget or the budget is negative, the output file should be empty. If one of the items is incorrect (no name, negative cost), the item should not be added to the list. Move to the next item. Each items cost and the total must be printed with 2 decimal points. The total number of items must be printed as an integer. Your program will be tested with GNU C++. Therefore, you are encouraged to work on Unix, or at least make sure that your code compiles and runs successfully on the server.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!