Java Console Error

Question:

My code isn’t running with the line Console c = new Console(); and it has worked with other java coding I’ve done on a different account but it doesn’t work now - does anyone now how to fix it?

Repl link:
This is my code:

import java.util.Random;

public class Main {

  Console c = new Console();//always leave this line in a java program

  public Main() {
// need this for anything to do with random numbers
    Random r = new Random();
// asks how many dice the user would like to roll and saves as a variable
  int numberofdice = c.inputInt("How many dice would you like to roll? Please only input a number \n");

  }
}

And it gives the error cannot find symbol for the console part of it

Console c = new Console();
int n = c.inputInt("input a number \n"); 

this is not standard api java.io.Console,
it’s custom console. If you don’t have original source code, you can write it like

import java.util.Scanner;

public class Console {
  Scanner sc = new Scanner( System.in);
  
  public int inputInt( String str) {
    System.out.print( str);
    return sc.nextInt();
  }
}