Question: A private integer instance variable named axles. A private integer instance variable named weight. A private double instance variable named fee. A constructor that takes

A private integer instance variable named axles.
A private integer instance variable named weight.
A private double instance variable named fee.
A constructor that takes two integer parameters and sets the instance variables axles and weight accordingly.
A method named calculateToll which takes no parameters and ret no value, the method should calculate the toll paid by each truck and the instance variable fee the toll value paid*.
Each truck arriving at the toll both is required to pay a toll of $5 per and $10 per half-ton of the truck's total weight. The weight shown in sample usage is in kilograms. Each ton is 1000 kilograms. Do not worr about truncated values due to integer division.
A method named displayReceipt which takes no parameters and no value, the method should display the transaction details as shown sample output.
Sample usage and output provided below.
Sample Usage:Sample Output:Axles: 5Weight: 13000 KilogramsToll paid: $285.0Axles: 6
A private integer instance variable named axles.

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 Programming Questions!