Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribed

2.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago