title: How do I create a running total using input from Scanner object
body: <p>I am writing a program which is supposed to calculate a running total, until the user inputs 999, at which point the total(not including 999) is supposed to the screen.</p>
  
  <p>I realise I'll probably have to deduct 999 from the total, but my issue is I cannot get it to spit out a total. I think the issue is that my Math class doesn't correctly increment the numTotal from the num variable. Please help.
  Thanks in advance</p>
  
  <pre><code>public class Program {
  
  public static void main(String[] args) {
  
      Scanner kb = new Scanner(System.in);
      String input = kb.nextLine();
      Scanner scn = new Scanner(input);
      int num = scn.nextInt();
      Math math1 = new Math(num,0);
      while(num != 999){
          math1.adder(num);
          input = kb.nextLine();
      }
  
      System.out.println(math1.getNumTotal());
  } //main
  
  }
  </code></pre>
  
  <p>end of class</p>
  
  <pre><code>public class Math {
  
  private int num;
  private int numTotal;
  
  public Math(int num, int numTotal){
      this.num = num;
  }
  
  
  
  //get//
  
  public int getNum(){
      return this.num;
  }
  
  public int getNumTotal(){
      return this.numTotal;
  }
  
  //set//
  
  public void setNumTotal(int value){
      this.numTotal = value;
  }
  
  public void setNum(int value){
      this.num = value;
  }
  
  //other
  public void adder(int num){
      numTotal = numTotal + num;
  }
  
  
  
  }
  </code></pre>
  
  <p>end of class</p>