Guest User

Untitled

a guest
Jan 17th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Calc {
  3.     public static void main (String args[]) {
  4.         for (;;) {
  5.             System.out.println("Enter operation");
  6.             Scanner keyboard = new Scanner(System.in);
  7.             String operation = keyboard.nextLine();
  8.             System.out.println("Enter first integer");
  9.             int firstInt = keyboard.nextInt();
  10.             System.out.println("Enter second integer");
  11.             int secondInt = keyboard.nextInt();
  12.             if (operation.equals("plus")) {
  13.                 System.out.println(firstInt + secondInt);
  14.             } else if (operation.equals("minus")) {
  15.                 System.out.println(firstInt - secondInt);
  16.             } else if (operation.equals("divide")) {
  17.                 System.out.println(firstInt / secondInt);
  18.             } else if (operation.equals("multiply")) {
  19.                 System.out.println(firstInt * secondInt);
  20.             }
  21.         }
  22.  
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment