Scanner not working. Any ideas on what is happening?

I am working on making a calculator with Java, and I am currently trying to see if my program works so far. I ran the code and got this error:

"
Exception in thread “main” java.util.NoSuchElementException: No line found
at java.base/java.util.Scanner.nextLine(Scanner.java:1554)
at Playground.main(Playground.java:16)
"

It seems that the problem is that my Scanner, scan1, is not being made. I tried changing the variable name, refreshing the page, deleting the code and putting it back, but nothing worked. Does anybody have any ideas on how to fix this or what to do? I have also posted my code below in case it helps.

[codebyte Java
import java.util.Scanner;
import java.util.ArrayList;

class Calculator {

public static void main(String[] args) {
  // Object Instances
  ArrayList<String> calculateThis = new ArrayList<String>();
  ArrayList<Integer> numbers = new ArrayList<Integer>();
  Random rand = new Random();

  System.out.println("Enter your math problem.");
  
  Scanner scan = new Scanner(System.in);
  String toCalculate = scan.nextLine();

  for (int i = 0; i < toCalculate.length(); i++){
    char letter = toCalculate.charAt(i);
    calculateThis.add("" + letter);
  }
}

}
[/codebyte Java]