
import java.util.Scanner; public class Calc5{ public static void main(String args[]){ Scanner obj = new Scanner(System.in); System.out.println("please enter operand1, operand2 and operator(+,-,x,/)"); int a = obj.nextInt(); int b = obj.nextInt(); double c ; char op = obj.nextChr ();
if(op == '+');
c = a+b;
System.out.println ("a" +"+"+ "b");
System.out.println("the result is=" + c);
if (op == '-');
c = a-b;
System.out.println ("operand1" +"-"+ "operand2");
System.out.println("the result is=" + c);
if (op == '/') ;
c= a/b;
System.out.println ("operand1" +"/"+ "operand2");
System.out.println("the result is=" + c);
if (op == '*');
c = a * b;
System.out.println ("operand1" +"x"+ "operand2");
System.out.println ("the result is=" +c);
} // end of main
} // end of class

import java.util.Scanner;
public class Calc5{
public static void main(String args[]) throws Exception{
Scanner obj = new Scanner(System.in);
System.out.println("please enter operand1: ");
int a = obj.nextInt();
System.out.println("please enter operand2: ");
int b = obj.nextInt();
double c ;
System.out.println("please enter operator(+,-,x,/): ");
char op = (char)System.in.read();
if(op == '+'){
c = a+b;
System.out.println ("a" +"+"+ "b");
System.out.println("the result is=" + c);
}
else if (op == '-'){
c = a-b;
System.out.println ("operand1" +"-"+ "operand2");
System.out.println("the result is=" + c);
}
else if (op == '/'){
c= a/b;
System.out.println ("operand1" +"/"+ "operand2");
System.out.println("the result is=" + c);
}
else if (op == '*'){
c = a * b;
System.out.println ("operand1" +"x"+ "operand2");
System.out.println ("the result is=" +c);
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.