Scanner input = new Scanner(System.in);
System.out.print("\tEnter student no.: \t");
long studNo = input.nextLong();
System.out.println(studNo);
If I enter 0914325
it only prints 914325
. I know because the data type is long
. I could use a String
data type but what if the user accidentally inputs a letter? Is there any way I could print a number starting at 0?