Computer Science, asked by rrockstar59, 3 months ago

write a program to input two integers and a charecter. The charecter contains any one of the arithmetic operators. Your program should check the operator entered and perform the operation

Answers

Answered by kamalrajatjoshi94
2

Answer:

import java.util.*;

public class Operation

{

public static void main(String args[ ])

{

Scanner in=new Scanner(System.in);

int a,b;

char ch;

System.out.println("Enter the numbers");

a=in.nextInt();

b=in.nextInt();

System.out.println("Enter the arithmetical operator");

ch=in.next().charAt(0);

switch(ch)

{

case '+':

System.out.println("The sum of the two numbers="+(a+b));

break;

case '-':

System.out.println("The difference of the two numbers="+(a-b));

break;

case '*':

System.out.println("The product of the two numbers="+(a*b));

break;

case '/':

System.out.println("The quotient of the two numbers="+(a/b));

break;

case '%'

System.out.println("The remainder of the two numbers="+(a%b));

break;

default:

System.out.println("Invalid Character");

}

}

}


Anonymous: which class program is it?
Similar questions