title: Car class with acceleration and braking
body: <p>I am in an intro to java class and I am having trouble with a car class that was assigned. Here are the instructions: 
  Write a class named Car that has the following fields (attributes):</p>
  
  <p><code>yearModel</code> (an int which hold's the car's year model)</p>
  
  <p><code>make</code> (a String which holds the make of the car)</p>
  
  <p><code>speed</code> (an int which holds the car's current speed)</p>
  
  <p>The <code>Car</code> class should have the following constructor and other methods:</p>
  
  <p><code>Constructor</code> - Accepts the car's <code>year</code> <code>model</code> and <code>make</code> as arguments.</p>
  
  <p><code>Accessors</code> (getters) for the object's <code>yearModel</code>, <code>make</code>, and <code>speed</code> fields</p>
  
  <p>Methods:
  <code>accelerate</code> - each time it is called, it should add 5 to the <code>speed</code> field
  <code>brake</code> - each time it is called, it should subtract 5 to the <code>speed</code> field</p>
  
  <p>Write a <code>Driver</code> class, the <code>DrivingSimulation</code> class, which does the following:</p>
  
  <p>Prompt the user for the <code>yearModel</code>, <code>make</code>, and <code>speed</code> values of a car.
  Create a <code>Car</code> object 
  Call the <code>accelerate</code> method 5 times - after each call, use the <code>accessor</code> method to display the current <code>speed</code> of the car
  Call the <code>brake</code> method 5 times - after each call, use the <code>accessor</code> method to display the current <code>speed</code> of the car</p>
  
  <p>I got most of it done but it is not receiving the speed input that I am putting, and is instead starting from default, 0. Here is my car class</p>
  
  <pre><code>  package drivingsimulation;
  
  /**
  *
  * @author Carlos
  */
  
  public class Car {
  private int yearModel;
  private String make;
  private int speed; 
  
  public Car(int yearModel, String make) {
      this.yearModel = yearModel;
      this.make = make;
  }
  
  public int getYearModel() {
      return yearModel;
  }
  
  public String getMake() {
      return make;
  }
  
  public int getSpeed() {
  
     System.out.println("You are going " + speed + " mph");
      return speed;
  
  }
  
  public void accelerate() {
  
       speed += 5;
  
  }
  
  
  public void brake () {
  
       speed-=5;
  
  }
  
  
  
  
  
  }
  </code></pre>
  
  <p>And here is my driver class:</p>
  
  <pre><code>/*
  
  package drivingsimulation;
  import java.util.Scanner;
  /**
   *
   * @author Carlos
   */
  public class DrivingSimulation {
  
  /**
   * @param args the command line arguments
   */
  public static void main(String[] args) {
  
      int yearModel=0;
      int speed=0;
      String make=null;
  
  
      Scanner keyboard = new Scanner (System.in);
  
      Car myCar = new Car(yearModel, make);
  
      System.out.println("What is the year of your car? ");
      yearModel = keyboard.nextInt();
  
      System.out.println("What is the make of your car? ");
      make = keyboard.next();
  
      System.out.println("How fast is your car going?  ");
      speed = keyboard.nextInt();
  
  
  
      for(int i=0; i&lt;5; i++){
  
  
          myCar.accelerate();
  
      }
  }
  
  }
  </code></pre>