import java.util.Scanner; public class Calculate { public static void main(String[] args) { int firstNumber,secondNumber,operand; Scanner input=new Scanner(System.in); //create scanner object to object input from keyboard //System.out.println("Pls enter ur choice between 1 to 4 below"); System.out.println("Enter number between 1 to 4 to choose operand"); System.out.println("1. ADDITION"); System.out.println("2. SUBTRACTION"); System.out.println("3. MULTIPLICATION"); System.out.println("4. DIVISON"); operand=input.nextInt(); System.out.print("Enter the first number:"); firstNumber=input.nextInt(); //read the first number(firstNumber) System.out.print("Enter the second number:"); secondNumber=input.nextInt();//read the second number(secondNumber) switch(operand) { case 1: System.out.println("The sum is = "+(firstNumber+secondNumber)); break; case 2: System.out.println("The answer is ="+(firstNumber-secondNumber)); break; case 3: System.out.println("The product is ="+(firstNumber*secondNumber)); break; case 4: System.out.println("The answer is ="+(firstNumber/secondNumber)); break; default: } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)