Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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

image text in transcribed
image text in transcribed
a3a.txt is below
image text in transcribed
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

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students explore these related Databases questions