0
what is used to enable the scanner class to accept an integer as an input? pls help
3 Answers
+ 3
.nextDouble();
.nextFloat();
.nextLine();
...
+ 3
Scanner scanner = new Scanner(System.in);
int input = scanner.nextInt();
+ 2
You can check how to "read" numerical data from a string in this code snippet
https://code.sololearn.com/cgMBmRs5dOgx/?ref=app
in your code, you can use your Scanner to read the user input as a string and then use the Integer.parseInt() method to read an integer number from this string.
So, in your example (where input is a scanner, and score1 is a variable of type int) that would be
score1=Integer.parseInt(input.next())