Question: 1. 2. Compile and run the following code: import java.util.Scanner class ScannerDemo { public static void main(String[] args) { System out.print(What is your name?); Scanner
1.

2.
![{ public static void main(String[] args) { System out.print("What is your name?");](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f4e5ee948a1_67866f4e5ee35341.jpg)
Compile and run the following code: import java.util.Scanner class ScannerDemo { public static void main(String[] args) { System out.print("What is your name?"); Scanner scanName = new Scanner(System in); String myString = scanName. nextLine(); System.out.print("How many countries have you visited?"); Scanner scanNum = new Scanner(System in); int myInt = scanNum nextInt (); System out.println(myString + has visited + my Int + countries."); } Question 4: My first Scanner: Create a small program named VotingRight that asks the user to enter his age. If the user is not old enough to vote, the program needs to print the number of years until the person is allowed to vote. Example of the output: How old are you? 11 You will be allowed to vote in 7 years. How old are you? 24 You have the right to vote
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
