Program 2 Shop application
You must write a small application in JAVA that stores items and their prices. Your program must:
- Create an array of item names. Use the following item names: Bread, Milk, Butter, Chips,
Honey, Soap, Towel, Carrots, Beans, Samp, Dress, Pants, Shoes, Socks. - Create an array of item prices. Use the following item prices: 15.50, 12.00, 56.00, 20.00, 45.00,
7.00, 75.00, 8.00, 5.00, 12.00, 200.00, 150.00, 400.00, 25.00. - Print every item name and its corresponding price. See the sample output given.
- Print the average price of all the items.
- Find the price of a specific item
a. Read the name of the item
b. Loop through the prices array and look for the specific item.
c. Print the price of the item
Sample output
Print every item name and its corresponding price.
Items in stock with pricesBread 15.5
Milk 12.0
Butter 56.0
Chips 20.0
Honey 45.0
Soap 7.0
Towel 75.0
Carrots 8.0
Beans 5.0
Samp 12.0
Dress 200.0
Pants 150.0
Shoes 400.0
Socks 25.0
Print the average price of all the items
The average price of items is 73.0
Find the price of a specific item – sample input and output
Sample run 1 Sample run 2
Item Look up
What item are you looking for?
Dress
The price of item Dress is 200.0
Item Look up
What item are you looking for?
hjgjg
Item hjgjgis not in the shop