I've just started learning Java (only my second day) but can anyone explain to me why this code doesn't work. Its code for a basic calculator every time i try to compile it says found Int but expected boolean. Thanks in advance.
import java.util.Scanner;
public class Calculator2{
public static void main (String[] args){
Scanner keyboard=new Scanner(System.in);
int x = keyboard.nextInt();
if(x = 1){
System.out.print("1st number: ");
Scanner scan = new Scanner(System.in);
int num1 = scan.nextInt();
System.out.print("\n2nd number: ");
int num2 = scan.nextInt();
int num3 = num1 + num2;
System.out.print("\nThe answer is: " + num3);
}
else if(x = 2){
System.out.print("1st number: ");
Scanner scan = new Scanner(System.in);
int num4 = scan.nextInt();
System.out.print("\n2nd number: ");
int num5 = scan.nextInt();
int num6 = num4 - num5;
System.out.print("\nThe answer is: " + num3);
}
else if(x = 3){
System.out.print("1st number: ");
Scanner scan = new Scanner(System.in);
int num7 = scan.nextInt();
System.out.print("\n2nd number: ");
int num8 = scan.nextInt();
int num9 = num7 * num8;
System.out.print("\nThe answer is: " + num3);
}
else{
System.out.print("1st number: ");
Scanner scan = new Scanner(System.in);
int num10 = scan.nextInt();
System.out.print("\n2nd number: ");
int nu11 = scan.nextInt();
int num12 = num10 / num11;
System.out.print("\nThe answer is: " + num3);
}
}
}