Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need a java program which Implement a simple program for a car rental program needs to consist of the following parts: insome An abstract
I need a java program which Implement a simple program for a car rental program needs to consist of the following parts: insome An abstract class Vehicle which stores thevehicle model and rental rate, as well as a public method getDescription that returns a description of the vehicle A class Car that inherits from Vehicle and adds an Enumeration for the size of the car with possible values compact, midsize, fullsize and premium A class Truck that inherits from Vehicle andadds a cargo capacity A class Rental that contains a Vehicle, a LocalDate for the pick up date and a LocalDate for the drop of date for the rental. It also needs to contain a method that calculates the total price of the rental by multiplying the number of days by the rate and a method that returns a description of the rental, which includes the total price. A class Midterm with a main method that o Creates an array of three Vehicle objects using the data shown in the sample run below o Prompts users to pick a vehicle, enter a pick up date and a drop off date o Creates a Rental object with that information and outputs its description.
Hint:
To calculate the number of days between
two
LocalDate objects date and date y
ou can
use
the following call, which returns a long value
:
java.time.temporal.ChronoUnit.DAYS.between
date
date
;
Sample Run of Program
Available vehicles:
COMPACT Toyota Yaris
Daily rate: $
TRUCK with cargo capacity: kg Ford F
Daily
rate: $
PREMIUM BMW i
Daily rate: $
Pick a vehicle by entering its number:
Please enter the pick up date:
Please enter year:
Please enter month:
Please enter day:
Please enter the drop off date:
Please enter year:
Please enter month:
Please enter day:
Rented vehicle:
COMPACT Toyota Yaris
Daily rate: $
Pick up date:
Drop off date:
Rental rate: $
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