title: simple calculator function in java
body: <p>in the initial stage ,by entering + or - or other symbol,i want that operation to be done and should get me the output..instead of doing whole operations(+,-,*,/) for every number i input.</p>
  
  <p>i tried many times,but still getting error ,even i am not knwing how to get the error corrected.pls provide me some suggestions..</p>
  
  <pre><code>Exception in thread "main" java.util.InputMismatchException
      at java.util.Scanner.throwFor(Scanner.java:909)
      at java.util.Scanner.next(Scanner.java:1530)
      at java.util.Scanner.nextInt(Scanner.java:2160)
      at java.util.Scanner.nextInt(Scanner.java:2119)
      at calculator.Calculator.main(Calculator.java:25
  
  )
  
  package calculator;
  
  import java.util.Scanner;
  
  public class Calculator {
      private static int valueA;
      private static int valueB;
      private static String operator;
      private static char operatorA;
  
      public int getValueA() {
          return valueA;
      }
  
      public int getValueB() {
          return valueB;
      }
  
  
      public static void main(String[] args) {
          Scanner keyboard = new Scanner(System.in);
          System.out.println("Enter problem.");
  
  
              valueA = keyboard.nextInt();
              valueB = keyboard.nextInt();
              operator = keyboard.next();
              operatorA = operator.charAt(0);
  
              int add =  '+' ;
              int minus = '-';
              int multiply = '*';
              int divide = '/';
  
              switch (operatorA) {
              case '+':
                  add=valueA + valueB;
                  System.out.println(add);
                  break;
  
              case '-':
                  minus = valueA - valueB;
                          System.out.println(minus);
                                 break;
  
              case '*':
                  multiply=valueA * valueB;
                  System.out.println(multiply);
                  break;
  
              case '/':
                  divide=valueA / valueB;
                  System.out.println(divide);
                  break;
  
              default:
                  System.out.println("unknown operator '" + operator + "'. Please try again.");
                  break;
              }
  
      }
  
  }
  </code></pre>