Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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 voteStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started