This is for JAVA Write a class named Car that has the follow
\\\\This is for JAVA
Write a class  named Car that has the following fields:
 
 • yearModel: The yearModel field is an int that holds the car\'s year model.
 • make: The make field is a String  object that holds the make of the car.
 • speed: The speed field is an int that holds the car\'s current speed.
 
 In addition, the class should have the following methods :
 
 • Constructor : The constructor should accept the car\'s year model and make as arguments .
 These values should be assigned to the object \'s yearModel and make fields. The
 constructor should also assign 0 to the speed field.
 • Accessor: The appropriate accessor methods should be implemented to access the values
 stored in the object \'s yearModel, make, and speed fields.
 • accelerate: The accelerate method should add 5 to the speed field when it is called.
 • brake: The brake method should subtract 5 from the speed field each time it is called.
 
 Demonstrate the class in a program that contains a Car object , and then calls the
 accelerate method five times. After each call to the accelerate method , get the current
 speed of the car and print it on a separate line. Then, call the brake method five times,
 each time printing the current speed of the car on a separate line.
________________________________________________________________
SAMPLE RUN #0: java Car of the program - expected outcome below:
5
Solution
Hi,
 //*******************************************************************
  // NOTE: please read the \'More Info\' tab to the right for shortcuts.
 //*******************************************************************
import java.lang.Math; // headers MUST be above the first class
// one class needs to have a main() method
 public class HelloWorld
 {
 // arguments are passed using the text field below this editor
 public static void main(String[] args)
 {
 Car myObject = new Car(2017,\"maruti\");
 for(int i=0;i<5;i++)
 {
 myObject.accelerate();
 myObject.Accessor();
 }
 for(int j=0;j<5;j++)
 {
 myObject.brake();
 myObject.Accessor();
 }
 }
 }
// you can add other public classes to this editor in any order
 public class Car
 {
 int yearModel;
 String make;
 int speed;
 public Car(int yearModel,String make)
 {
 this.yearModel=yearModel;
 this.make=make;
 this.speed=0;
 }
 public void accelerate()
 {
 speed=speed+5;
 }
 public void brake()
 {
 speed=speed-5;
 }
 public void Accessor()
 {
 System.out.println(speed);
 }
   
 }


