waltermilner

Untitled

Sep 27th, 2014
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.41 KB | None | 0 0
  1. Scanner scanner=new Scanner(System.in);
  2.        String line = scanner.nextLine();
  3.        while (!line.equals("end"))
  4.        {
  5.            int num1=line.charAt(0)-'0';
  6.            int num2=line.charAt(2)-'0';
  7.            char op = line.charAt(1);
  8.            int result=0;
  9.            if (op=='+')
  10.                result=num1+num2;
  11.            System.out.println(result);
  12.            line = scanner.nextLine();
  13.        }
Advertisement
Add Comment
Please, Sign In to add comment