Question: In JAVA*** Make a Car class that has 3 fields: model of car (String constant) , speed of a car (double datatype) and the distance
In JAVA***
Make a Car class that has 3 fields: model of car (String constant) , speed of a car (double datatype) and the distance travelled. The class, in addition to constructor, accessors and mutators, should have a method that calculates and returns the time taken by the car ( HINT: Time = Distance/Speed). The client program (one with main() ) should have following two methods
an equals method that accepts 2 Car objects as parameter to compare whether two cars are traveling with same speed and have covered same distance. Return type is boolean.
toString method is used to display all output statements. It accepts two car objects and the result of equals method as parameters. It displays both the cars model, time taken by each and the result of equals() on the terminal screen.
Demonstrate the class in a program that asks the user to enter the fields for two cars.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
