Question: Create a class called PetrolPurchase to represent information about the petrol you purchase. The class should include five pieces of information in the form of

Create a class called PetrolPurchase to represent information about the petrol you purchase. The class should include five pieces of information in the form of instance variables - the station location, the quantity of purchase in litres, the type of petrol, the price per litre and the percentage of discount.
Your class should have a constructor that initiates the five instance variables, accessor methods, mutator methods, payment method, a str-method that returns the information of instance variable and a repr-method to indicate how an object can be created.
The following shows the interactions:
Enter the station: Bukit Timah
Enter quantities in litres: 30
Enter type of petrol: Super 98
Enter price of petrol: 3.50
Enter discount: 25
The system displays the following summary purchased:
Summary of purchase
Station: Bukit Timah
Quantity: 30.00
Petrol type: Super 98
Unit price: 3.50
Discount: 25.00%
Total cost: $105.00
Total discount (25.00%): $ 26.25
Final payment: $ 78.75
The customer decides to add in some for more litres of petrol:
Additional quantity: 40
Final Summary of purchase
Station: Bukit Timah
Quantity: 70.00
Petrol type: Super 98
Unit price: 3.50
Discount: 25.00%
Total cost: $245.00
Total discount (25.00%): $ 61.25
Final payment: $ 183.75
Finally the call of _repr_ object was constructed:
function to describe how the final
The object was constructed according to:
PetrolPurchase ("Bukit Timah", 70.0, "Super 98",3.5,25.0)

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!