Question: Declare a Scanner and initialize it to read from the keyboard. Declare integer variables named integer0 and integer1. Prompt the user as follows: Enter first

Declare a Scanner and initialize it to read from the keyboard.

Declare integer variables named integer0 and integer1.

Prompt the user as follows: "Enter first integer: " and read integer0 from the keyboard.

Prompt the user as follows: "Enter second integer: " and read integer1 from the keyboard.

Write an if statement that prints "First integer is larger than the second." when integer0 > integer1.

Add an else if statement that prints "Second integer is larger than the first." when integer1 > integer0.

Finish with an else statement that prints "Both integers are equal." when integer0 == integer1.

Declare a String variable named myString.

Use the Scanner from the previous section to read it, using the prompt: "Enter a state: ".

NOTE: You must use the next() method in Scanner, not nextLine().

Write a switch statement that does the following:

Prints "Southern State" if myString is "Alabama" or "Florida".

Prints "Western State" if myString is "Colorado" or "Utah".

Prints "Northern State" if myString is "Michigan" or "Wisconsin".

Prints "Eastern State" if myString is "Delaware" or "Maine".

Prints "Not sure where that is, must be in the Midwest!" for any other value of myString.

sample Output

 Enter first integer: 123 Enter second integer: 234 Second integer is larger than the first. Enter a state: Colorado Western State

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!