Question
Java Write a class called Car that contains instance data that represents the make, model, year, and price of the car. Define the Car constructor
Java
Write a class called Car that contains instance data that represents the make, model, year, and price of the car. Define the Car constructor to initialize these values. Include getter and setter methods for all instance data, add a method called isAntique that returns a Boolean indicating if the car is an antique (if it is equal to or more than 25 years old). In Car class prompt user to enter values of instance data. Count cars entered. Sum total price. Add method called avgCarPrice to return average price of all cars. Have a toString method that returns a one-line description of each cars instance data values and whether or not it is an antique. Create a driver class called CarTest, whose main method instantiates and updates a few Car objects. e.g. car1 car2 car3. Looping is not necessary for this program. Get from Car class calculated values and print on new line the quantity of all cars, total price of all cars, and average price of all cars. Format for currency two decimal places.
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