Write a class that represents a car object A Car has the fol
Solution
CarTester.java
 import java.util.Random;
 import java.util.Scanner;
public class CarTester {
  
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.print(\"Please enter the make and model of the case: \");
        String make = scan.next();
        int year = scan.nextInt();
        Car c = new Car(make, year);
        System.out.println(\"New car created! \"+c.getMake()+\", \"+c.getYearModel());
        Random r = new Random();
        for(int i=0; i<r.nextInt(42)+1;i++){
            c.accelerate();
            System.out.println(\"The current speed is \"+c.getSpeed());
        }
        int j=0;
        for(j=0;c.getSpeed()>0;j++){
            c.brake();
        }
        System.out.println(\"The current speed is \"+c.getSpeed()+\" and the brakes were aaplied \"+j+\" times\");
    }
}
Car.java
 public class Car {
    private int yearModel;
    private String make;
    private int speed;
    public Car(String make, int year){
        this.make=make;
        this.yearModel = year;
        this.speed=0;
    }
    public int getYearModel() {
        return yearModel;
    }
    public void setYearModel(int yearModel) {
        this.yearModel = yearModel;
    }
    public String getMake() {
        return make;
    }
    public void setMake(String make) {
        this.make = make;
    }
    public int getSpeed() {
        return speed;
    }
    public void setSpeed(int speed) {
        this.speed = speed;
    }
    public void accelerate(){
        if(speed + 5 <= 210){
        speed+=5;
        }
    }
    public void brake(){
        if(speed - 5 >= 0){
        speed-=5;
        }
    }
 }  
Output:
Please enter the make and model of the case: Tberson 2006
 New car created! Tberson, 2006
 The current speed is 5
 The current speed is 10
 The current speed is 15
 The current speed is 20
 The current speed is 25
 The current speed is 30
 The current speed is 35
 The current speed is 40
 The current speed is 0 and the brakes were aaplied 8 times


