Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

  

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 get Payment 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 is 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: 98.52 Discount (15%): 13.58 Amount to pay: 76.95 The customer decides to add in some for more litres of petrol: Enter addtional quantity of petrol: 15.5 Your new purchased price Station: Bukit Timah Total liter: 41.00 Petrol type: Super 99 Price per liter: 3.55 Actual cost: 145.55 Discount (15%): 21.83 Amount to pay: 123.72 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: 41.88 Petrol type: Super 99 Price per liter: 3.55 Actual cost: 145.55 Discount (15%): 21.83 Amount to pay: 123.72 The following shows the UML diagram of the two classes: static void mandlitinalarasi Lab 3 - - -String station -double quantity -Sting type -double price -int discount PetrolPurchase PatrolPurchase(Strings, double a String t, double p, int d) PetrolPurchase(PatrolPurchase pp) o-String getStation String getType o-double getQuantity double getPrice +int getDiscount Ovoid setStation(String station) Usual programming practice must be respected: file header declarations - indentations and alignment of statements void setType(String type) void setPrice(double price) void setQuantity(double quantity) Ovoid setDiscaountont discount -void setinfo (Strings, double q, Stringt double p, int d) -double computePayment double getPayment void printinfo avoid long statement comment statements well partition your screen to have clear interactions and displays. use of other constructors to construct objects etc For printing, you can ONLY use printf method in this lab, i.e. print and println methods are not allowed in this lab.

Step by Step Solution

3.48 Rating (165 Votes )

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

Systems analysis and design

Authors: kenneth e. kendall, julie e. kendall

8th Edition

135094909, 013608916X, 9780135094907, 978-0136089162

More Books

Students also viewed these Programming questions

Question

4. How does a sex-linked gene differ from a sex-limited genepg105

Answered: 1 week ago

Question

6. How does an epigenetic change differ from a mutationpg105

Answered: 1 week ago