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 07:30
What is the original authority for copyright laws
Answers: 1
question
Computers and Technology, 23.06.2019 10:00
How do i delete my account on this because i didn't read this agreements and also i put age at xd
Answers: 1
question
Computers and Technology, 23.06.2019 12:00
If you embed a word table into powerpoint, what happens when you make edits to the embedded data? a. edits made to embedded data change the data in the source file; however, edits made to the source file will not be reflected in the embedded data. b. edits made to embedded data will change the data in the source file, and edits made to the source file will be reflected in the embedded data. c. edits made to embedded data don't change the data in the source file, nor will edits made to the source file be reflected in the embedded data. d. edits made to embedded data don't change the data in the source file; however, edits made to the source file will be reflected in the embedded data.
Answers: 1
question
Computers and Technology, 24.06.2019 02:10
Which sentences describe the things you need to ensure while creating a sketch and a drawing? while an artistic or creative drawing is a creative expression, a technical drawing is an informative expression. you need to create accurate and neat drawings to convey accurate information. a technical drawing clearly conveys its meaning or information, and does not leave room for interpretation maintain a good speed while creating drawings
Answers: 1
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, 24.06.2019 11:30
Questions on the website: 13722367