So I am trying to make a calculator in VSCode but for some reason, my scanner is not running. Here is the full code for my project so far...
import java.util.Scanner;
class main { //Main
public static void main(String[] args) {
int firstnumber = 0;
int secondnumber = 0;
String Operator = "-";
boolean erase = true;
Scanner scan = new Scanner(System.in);
while (erase = true) { //While Loop (main)
System.out.println("Enter First Number");
firstnumber = scan.nextInt();
System.out.println("Enter Second Number");
secondnumber = scan.nextInt();
System.out.println("Select Operator.");
System.out.println("For Multiplaction: Type X");
System.out.println("For Division: Type %");
System.out.println("For Addition: Type +");
System.out.println("For Subtraction: Type -");
Operator = scan.nextLine()
} //While Loop (main)
}
} //Main
For some reason when I run that code it runs the first two scanners but then fails to run the one that asks for the operator. If anyone knows why I would be pleased to know.