Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Programming Exercise 6-2 (10 Points) Define a class called Car. This class is us

ID: 3730958 • Letter: P

Question

Programming Exercise 6-2 (10 Points) Define a class called Car. This class is used to simulate a car driving, and calculates how far the car was able to drive based on fuel tank size and fuel efficiency. The class should have integer variables for fuel tank size and fuel efficiency. The class should have a String variable for car model name. The class should have a "drive" method that returns a double representing the distance driven, determined by multiplying the fuel tank size by the fuel efficiency. Write a test program that creates multiple Car objects with the following properties: Toyota Corolla, 13 gallon tank, 30 mpg Ford F-150, 30 gallon tank, 20 mpg Toyota Prius, 9 gallon tank, 45 mpg Take each out for a test drive and output the distance driven.

Explanation / Answer

Car.java

TestMain.java

Sample Output:

Distance driven: 390.0Meters
Distance driven: 600.0Meters
Distance driven: 405.0Meters

Thanks