please answer this program correctly
Attachments:
Answers
Answered by
2
import java.util.*;
public class operator
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
double n1,n2,r;
char ch;
System.out.println("Enter two numbers = ");
n1 = in.nextDouble();
n2 = in.nextDouble();
System.out.println("enter + for addition, - for subtraction , * for multiplication and / for division =");
ch = (char)in.next();
switch(ch)
{
case '+': r = n1+n2;
System.out.println(n1+" + "+n2+" = "+r);
break;
case '-':
r = n1-n2;
System.out.println(n1+" - "+n2+" = "+r);
break;
case '*':
r= n1*n2;
System.out.println(n1+" * "+n2+" = "+r);
break;
case '/': r= n1/n2;
System.out.println(n1+" / "+n2+" = "+r);
break;
default :System.out.println("invalid choice");
}
}
}
mn121:
please mark it as brainliest..
Similar questions
India Languages,
7 months ago
Math,
7 months ago
Math,
7 months ago
Math,
1 year ago
Math,
1 year ago