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, 21.06.2019 18:30
Given the following code: if (n == 2) { k -= 2; } else if (n == 3) { k -= 3; } can be rewritten as: if (< condition > ) { < assignment statement > ; } assume that evaluating < condition > does not change the values stored in n and k. which of the following could be used as < assignment statement > ? k -= n; k -= 1; k -= 2; k += n; k = n - k;
Answers: 2
question
Computers and Technology, 22.06.2019 14:00
Which database model is best used for data warehouse and data mining
Answers: 3
question
Computers and Technology, 23.06.2019 02:00
Read this excerpt from helen keller’s autobiography, the story of my life. have you ever been at sea in a dense fog, when it seemed as if a tangible white darkness shut you in, and the great ship, tense and anxious, groped her way toward the shore with plummet and sounding-line, and you waited with beating heart for something to happen? i was like that ship before my education began, only i was without compass or sounding-line, and had no way of knowing how near the harbour was. "light! give me light! " was the wordless cry of my soul, and the light of love shone on me in that very hour. . the morning after my teacher came she led me into her room and gave me a doll. the little blind children at the perkins institution had sent it and laura bridgman had dressed it; but i did not know this until afterward. when i had played with it a little while, miss sullivan slowly spelled into my hand the word "d-o-l-l." i was at once interested in this finger play and tried to imitate it. when i finally succeeded in making the letters correctly i was flushed with childish pleasure and pride. running downstairs to my mother i held up my hand and made the letters for doll. i did not know that i was spelling a word or even that words existed; i was simply making my fingers go in monkey-like imitation. in the days that followed i learned to spell in this uncomprehending way a great many words, among them pin, hat, cup and a few verbs like sit, stand and walk. based on this excerpt, which words best describe helen keller?
Answers: 2
question
Computers and Technology, 23.06.2019 09:30
You wanted to look up information about alzheimer's, but you were unsure if it was spelled "alsheimer's" or "alzheimer's." which advanced search strategy would be useful? a) a boolean search b) using a wild card in your search c) trying different search engines d) doing a search for "alsheimer's not alzheimer's" asap. ill give brainlist.
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
Business, 26.07.2021 17:30
question
Mathematics, 26.07.2021 17:30
question
Chemistry, 26.07.2021 17:30
Questions on the website: 13722361