Question: a3a.txt is below A classic application program is the shopping list a way of keeping track of which groceries or other items need to be

 a3a.txt is below A classic application program is the shopping list
a way of keeping track of which groceries or other items need
a3a.txt is below
to be bought, and which of them have already been purchased. Your

A classic application program is the shopping list a way of keeping track of which groceries or other items need to be bought, and which of them have already been purchased. Your answer to this question will implement such a shopping list, and simulate a users changes to the list with data read in from a text file. First, you will need a class to represent items in the list. Objects of this class will contain two instance variables, a String name of the desired item, and an int quantity that needs to be purchased Secondly, you will need two Arraylists in your program. The first list will keep track of items that sill eed to be bought (call this the shopping list), and the quantity needed. The second will keep track of the items purchased, and the quantity that has been purchased (call this the purchase list) data file used as input to the program will consist of lines containing one of three commands. The first of these is add, ed by a quaniy and an item name, separated by commas. This will add to the shopping list if an item with that increase the quantity desired by the given number. Otherwise, add a new item to the list with that name name already exists, and quantity. The second command is buy, which is also followed by a quantity and an item name. This will add to the purchase list in a similar fashion. Also, if an item with that name is already in the shopping list, reduce the quantity desired by that number. If the quantity of that item reaches zero (or less), remove it from the shopping list Finally, the list command should print out both Rists, showing both the quantity and the item name, one item per line. For example, the data file add, 3, loaf of bread add, 2, jug of milk list buy, 2, 1oaf of bread add, 4, loaf of bread buy,3, jug of milk buy,1,stick of butter 11st will display something similar to the following

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!