Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

java
image text in transcribed
image text in transcribed
image text in transcribed
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 and a copy constructor to duplicate the objects. Provide a set and a get method for each instance variables (even my UML diagram didn't show all of them ...). In addition, include a method called getPayment that gets the net purchase amount computed in the computePayment method. Write a java program with two classes (see UML diagram) defined in one class and PetrolPurchase another independent class. The following shows the interactions: Enter the station: Bukit Timah Enter quantity in liter: 25.5 Enter type of petrol: Super 99 Enter price of petrol: 3.55 Enter discount: 15 The system displays the following summary purchased: Summary of your purchase Station: Bukit Timah Total liter: 25.50 Petrol type: Super 99 Price per liter: 3.55 Actual cost: 90.52 Discount (156): 9.05 Amount to pay: 76.95 The customer decides to add in some for more litres of petrol: Enter addtional quantity of petrol: 10.5 Your new purchased price Station: Bukit Timah Total liter: 36.00 Petrol type: Super 99 Price per liter: 3.55 Actual cost: 127.80 Discount (159): 12.78 Amount to pay: 108.63 The company usually give a duplicate copy to customer. Invoke the copy constructor to have this duplicate copy: Duplicate the same object Station: Bukit Timah Total liter: 36.00 Petrol type: Super 99 Price per liter: 3.55 Actual cost: 127.80 Discount (158): 12.78 Amount to pay: 108.63 The following shows the UML diagram of the two classes: Lab_3 PetroPurchase 5-static Scanner input **static void mainiStringi args) -String station - double quantity - String type - double price - int discount +Petrolpurchase(Strings, double 4. Stringt double p, int d) +Petro Purchase(PetrolPurchase pp) String getStation String getType + double getQuantity double getPrice + int getDiscount *void setStation(String station) void setType(String type) void setPrice(double price) e void setOuantity(double quantity o+void setDiscaountint discount) -void setinfo(Strings, double 4. Stringt double p, int a - double computePaymento double getPaymento void printinfo Usual programming practice must be respected: - file header - declarations - indentations and alignment of statements - avoid long statement - comment statements - well partition your screen to have clear interactions and displays. use of other constructors to construct objects etc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

LO1 Identify why performance management is necessary.

Answered: 1 week ago