Complete the code to create a Scanner object to read input from the keyboard.
Scanner scanner = new [1](System.in);
The Scanner class is used to read input from various sources. To read from the keyboard, you create a Scanner object with System.in as the input stream.
Complete the code to read an integer value from the user using Scanner.
int number = scanner.[1]();To read an integer from the user, use the nextInt() method of Scanner.
Fix the error in the code to read a string input from the user.
String name = scanner.[1]();To read a whole line of text including spaces, use nextLine(). Other methods read tokens or numbers.
Fill both blanks to read a double value and then close the Scanner.
double value = scanner.[1](); scanner.[2]();
Use nextDouble() to read a double value. Always close the Scanner with close() to free resources.
Fill all three blanks to read a string, an integer, and then print them.
String name = scanner.[1](); int age = scanner.[2](); System.out.println([3] + ": " + age);
Use nextLine() to read the full name, nextInt() to read the age, and print the name and age together.