subject

Write a java program to record the list of items to buy in a grocery store and compute the total price based on the quantity and unit price of each of the items. For this program, you are asked to write three classes: GroceryList Class: this class represents a list of items to buy in a grocery store. You should use an array field to store the grocery items and to keep track of the number of items as you add it to the list. Since you are lining up in the Express Checkout line, the maximum number of items is 10. This class should have a constructor that initializes the array of Grocery Item (next Class) based on the maximum number and setting the number of item count to zero. This class should also have methods to add (GroceryItems item), getTotalCost( ), and display( ) the entire grocery list items. NOTE, no getter( ) or setter( ) methods.
(8 points) GroceryItem Class: this class represents each of the item for the grocery list array (GroceryList [ ] ). This class should have a item name, quantity, and a pricePerUnit fields plus a getCost( ) method to compute the cost of each item ( quantity * pricePerUnit ). You should use the constructor (argument…) to build each of the item for the GroceryList. Note. No getter( ) or setter( ) .
TestGroceryList Class: this is the class with the main (Strings [ ] args) method that uses the above two classes to build the grocery list based on each of the grocery items.
(should use the toString ( ) method to display class attributes. We will discuss the toString( ) method this week in class)
Your program should display the following:
Grocery list items =
3 of apple 0.5 each
5 of pear 0.35 each
6 of peach 0.25 each
total cost = 4.75

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 01:30
Negative methods of behavior correction include all but this: sarcasm verbal abuse setting an example for proper behavior humiliation
Answers: 1
question
Computers and Technology, 23.06.2019 04:00
Write a method that takes in an array of point2d objects, and then analyzes the dataset to find points that are close together. be sure to review the point2d api. in your method, if the distance between any pair of points is less than 10, display the distance and the (x,y)s of each point. for example, "the distance between (3,5) and (8,9) is 6.40312." the complete api for the point2d adt may be viewed at ~pf/sedgewick-wayne/algs4/documentation/point2d.html (links to an external site.)links to an external site.. try to write your program directly from the api - do not review the adt's source code.
Answers: 1
question
Computers and Technology, 23.06.2019 08:00
Which argument is not a valid filter? does not equal this quarter filter by cell color all of these are valid filter arguments.
Answers: 2
question
Computers and Technology, 23.06.2019 12:00
If you're using an existing powerpoint presentation that will receive new slides based on a word outline, select the a. slide that will appear after the new slides. b. first slide in the presentation. c. slide that will appear before the new slides. d. last slide in the presentation.
Answers: 2
You know the right answer?
Write a java program to record the list of items to buy in a grocery store and compute the total pri...
Questions
question
Chemistry, 16.10.2020 06:01
question
Social Studies, 16.10.2020 06:01
question
Mathematics, 16.10.2020 06:01
question
Social Studies, 16.10.2020 06:01
question
Mathematics, 16.10.2020 06:01
question
Mathematics, 16.10.2020 06:01
question
Mathematics, 16.10.2020 06:01
Questions on the website: 13722367