Question: CODE IN JAVA PLEASE Goals Understand inheritance and method overriding Description A grocery store sells food based on either the number of units or the

CODE IN JAVA PLEASE

Goals

Understand inheritance and method overriding

Description

A grocery store sells food based on either the number of units or the weight. For example, apples are sold by the kilogram while boxes of juice are sold based on the number of units the customer wishes to purchase. The store offers a discount for large purchases:

  • If the number of units of specific item is greater than 5, the customers gets one of them for free. For example, the customer buys 7 juice boxes pays for 6.
  • If the weight of a product is greater than 3 kg, the customer gets 10% discount on that particular product. For example, the customer buys 3.5 kg of apples pays 90% of the price for the apples.

The store needs a program to calculate the total bill for each customer. Such program will read a list of items purchased and the number of units or weight of each item. Each line in the bill consists of:

ProductName ProductPrice Unit/WeightIndicator Quantity/Weight

The list of items will be terminated by end keyword. The data will look like this:

Juice 10 unit 7

Apples 3 weight 3.5

Cereal 5 unit 3

Gum 1 unit 15

Pears 3.5 weight 5 end

The program should read the data from the console, calculate the total price of the items purchased and print it out.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!