Write a Java program that prompts the user to input two real-numbers along
with an operator [/ * % + –] and performs the required computation.with using keyboard input
Answers
Answer:
ANSWER
Explanation:
import java.io.*;
class pro1
{
public static void main(String args[])throws IOException
{
InputStreamReader ISR = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(ISR);
int a, b, add, sub, mul, div;
System.out.println("+ for addition");
System.out.println("- for subtraction");
System.out.println("* for multiplication");
System.out.println("/ for division");
System.out.println("Enter the value of A");
String v1 = in.readLine();
a = Integer.parseInt(v1);
System.out.println("Enter the value of B");
String v2 = in.readLine();
b = Integer.parseInt(v2);
System.out.println("Enter your choice");
char choice =(char)in.read();
if(choice == '+')
{
add = a+b;
System.out.println("Addition = " + add);
}
else if(choice == '-')
{
sub = a-b;
System.out.println("Subtraction = " + sub);
}
else if(choice == '*')
{
mul = a*b;
System.out.println("Multiplication = " + mul);
}
else if(choice == '/');
{
div = a/b;
System.out.println("Division = " + div);
}
}
}
plz mark me as the brainliest plz