import java.util.*;
public class testing
{
public static void main (String[] args) {
int a;
int b;
int calculation;
char symbol;
Scanner input=new Scanner (System.in);
System.out.println("Enter first integer = ");
a=input.nextInt();
System.out.println("Enter second integer = ");
b=input.nextInt();
System.out.println("Enter your choice (+,-,*,/)");
symbol=input.charAt();
switch (symbol) {
case '+' :
calculation = a+b;
System.out.printf("Addition is %d\n", calculation);
break;
case '-' :
calculation = a-b;
System.out.printf("Subtraction is %d\n", calculation);
break;
case '*' :
calculation = a*b;
System.out.printf("Multiply is %d\n",calculation);
break;
case '/' :
calculation = a/b;
System.out.printf("Division is %d\n", calculation);
break;
default :
System.out.printf("Enter valid value = ");
}
}
}
Sorry. It my first post to this website. Actually, I wanted to make calculator. When I wanted to compile my it get error like this:-
found : int
required: char
symbol=input.nextInt();
^
1 error
I knows there is an error in my coding. It just i don`t how to make correction of my coding. Please help. Beside i`m just begin to learn java recently.