Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Calc {
- public static void main (String args[]) {
- for (;;) {
- System.out.println("Enter operation");
- Scanner keyboard = new Scanner(System.in);
- String operation = keyboard.nextLine();
- System.out.println("Enter first integer");
- int firstInt = keyboard.nextInt();
- System.out.println("Enter second integer");
- int secondInt = keyboard.nextInt();
- if (operation.equals("plus")) {
- System.out.println(firstInt + secondInt);
- } else if (operation.equals("minus")) {
- System.out.println(firstInt - secondInt);
- } else if (operation.equals("divide")) {
- System.out.println(firstInt / secondInt);
- } else if (operation.equals("multiply")) {
- System.out.println(firstInt * secondInt);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment