Complete the code to print a message to the console.
System.out.[1]("Hello, world!");
The println method prints the message and moves to a new line.
Complete the code to read a line of input from the user.
Scanner scanner = new Scanner(System.in); String input = scanner.[1]();
The nextLine() method reads a full line of text from the user.
Fix the error in the code to correctly read an integer input.
Scanner scanner = new Scanner(System.in); int number = scanner.[1]();
The nextInt() method reads an integer value from the user.
Fill both blanks to create a program that reads a name and prints a greeting.
Scanner scanner = new Scanner(System.in); String name = scanner.[1](); System.out.[2]("Hello, " + name + "!");
nextInt() to read a name.print() instead of println().Use nextLine() to read the name and println() to print the greeting with a new line.
Fill all three blanks to read two numbers and print their sum.
Scanner scanner = new Scanner(System.in); int num1 = scanner.[1](); int num2 = scanner.[2](); System.out.[3]("Sum: " + (num1 + num2));
nextLine() to read integers.print() instead of println().Use nextInt() twice to read integers and println() to print the sum with a new line.
