Question: IN JAVA. Question 3 (Simple Class Exercise) Define a class named Car that stores information about a car. It should comprise of the following: 1.
IN JAVA.


Question 3 (Simple Class Exercise) Define a class named Car that stores information about a car. It should comprise of the following: 1. 2. Private instance variables to store age of the car, its type (sedan or suv) and its cost. 4 constructors: a. No argument (sets age to 0, type to sedan and cost to 32000). b. one argument constructor (sets cost to a value, age to 0 and type to sedan) c. two argument constructor (sets age to a value, cost to a value, and type to sedan) three argument constructor (sets age to a value, cost to a value, and type to value sedan or suv) d. 3. 4. 3 Accessor methods: - methods to return age, type and cost respectively. 5 Mutator methods: - 3 methods for setting the three values independently, a method to set all three values and a method to set only age and cost of the car. 5. A public method called estimatePrice) that returns the cost of a car based on type and age. A sedan costs $32000, depreciates 10% every year in first five years and 5% every year afterwards. An SUV costs $45000, depreciates 8% every year in the first five years and 4% every year afterwards. 6. A toString) method that returns the type of the car as well as it's age and cost. 7. An equals() method to test for equality of two objects of class car based on type and age 8. isLessThan() and isGreaterThan) method to compare between the prices of two objects of class car
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
