Computer Science, asked by mdmahfoozalam142004, 4 months ago

Write a program to read two numbers and an operator(+, -, *, / and %)

and perform the arithmetic operation based on the input operator.(using

switch case)​

Answers

Answered by mishajain100
19

Answer:

import java.util.*;

class Calculator

{

   static void main()

   {

       Scanner sc = new Scanner(System.in);

       System.oout.println("Enter two integers");

       int a = sc.nextInt();

       int b = sc.nextInt();

       System. out.println("Enter an operator (+, -, *, /, %)");

       char ch = sc.next().charAt(0);

       switch(ch)

       {

           case '+':

           System.out.println("Sum: " + (a + b));

           break;

           case '-':

           System.out.println("Difference: " + (a - b));

           break;

           case '*':

           System.out.println("Product: " + (a * b));

           break;

           case '/':

           System.out.println("Quotient: " + (a / b));

           break;

           case '%':

           System.out.println("Remainder: " + (a % b));

           break;

           default:

           System.out.println("Incorrect choice entered");

           break;

       }

   }

}

Hope this helps you!! Pls mark as brainliest!

Similar questions