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
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