Question
Write a class named RentalCar that has the following attributes: yearModel- This field is an integer that holds the car's year model. make- This field
Write a class named RentalCar that has the following attributes:
yearModel- This field is an integer that holds the car's year model.
make- This field references a String object that holds the make of the car.
plateNumber- This field references a String object that holds the car's plate number.
rentalPrice- This field is a double that holds car's rental rate.
In addition, the class should have the following constructor and other methods:
Constructor - The constructor should accept the car's year model, make and plate number as arguments. These values should be assigned to the objects yearModel, make and plateNumber fields. The constructor should also assign 2000 to the rentalPrice field.
Accessors - Appropriate accessor methods should get the values stored in an object's yearModel, make, plateNumber and rentalPrice fields.
A method named payment() to calculate and return the total payment for the car rental. To get the total payment, you can use the following formula:
total payment-(2 price) -(2 x rental price x(10% discount))
Write a java application named RentalCarDemo to demonstrate RentalCar class. Prompt the user to input all the details needed. Then calculate and display the total payment.
Example of the program output is given below:
One World Auto Rental
Year model 2010
Make Porsche
Plate Number wW 2011
T Rental price is RM2000,00
Rental days is fixed as 2 day and discount is 10%
Total Pavnent is RM1600 00
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started