Final Review Question 2 // Predict the output. Show calculations to justify your answer. // *********************************************** // Source code file Main.java // *********************************************** public class Main { public static void main(String[] args) { Car c1 = new Car("1G6AF5SX6D0125409", "silver"); System.out.println(c1); for(int i = 1; i <= 5; i++) { c1.pressAccelerator( ); } c1.drive(2.0); for(int i = 1; i <= 2; i++) { c1.pressBrake( ); } c1.drive(1.0); System.out.println(String.format( "c1 location: %.2f", c1.getLocation( ))); SportsCar c2 = new SportsCar( "2H7BG5TY2E0243862", "red"); System.out.println(c2); for(int i = 1; i <= 5; i++) { c2.pressAccelerator( ); } c2.drive(2.0); for(int i = 1; i <= 3; i++) { c2.pressBrake( ); } c2.drive(1.0); System.out.println(String.format( "c2 location: %.2f", c2.getLocation( ))); } } // *********************************************** // Source code file Car.java // *********************************************** public class Car { private String vin, color; protected double location, speed; protected double maxSpeed; protected double acceleration; public Car(String theVin, String theColor) { vin = theVin; color = theColor; location = 0.0; speed = 0.0; maxSpeed = 100.0; acceleration = 10.0; } public String getVin() { return vin; } public String getColor() { return color; } public double getLocation() { return location; } public double getSpeed() { return speed; } public void pressAccelerator( ) { speed += acceleration; if (speed >= maxSpeed) { speed = maxSpeed; } } public void pressBrake( ) { speed -= 20; if (speed < 0) { speed = 0; } } public void drive(double theTime) { location += speed * theTime; } @Override public String toString( ) { return String.format( "car: VIN=%s Color=%s ", vin, color); } } // *********************************************** // Source code file: SportsCar.java // *********************************************** public class SportsCar extends Car { public SportsCar(String theVin, String theColor) { super(theVin, theColor); maxSpeed = 200; acceleration = 20; } @Override public String toString( ) { return "sports" + super.toString( ); } }