Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A. Code a while loop that will only let the user exit if the correct secret word is entered. The error message, INVALID secret word!

A. Code a while loop that will only let the user exit if the correct secret word is entered. The error message, INVALID secret word! Try again!, prints every time the loop is entered. If the user enters the correct secret word and before exiting the loop, a congratulatory message prints, Congratulations! Youve figured out the secret word!. The real secret word as a string literal is Bazinga and the variable to store the word entered by the user is secretWord. Assume the input variable for the Scanner class is already declared. HINT: This is a sentinel-controlled loop. Use the equals method from the String class. You should negate the result of the equals method.

B. A boolean variable called check is initialized to true. Code a while loop that keeps executing when door has a value other than 1, 2, or 3. The error message Invalid door number! Try again! prints when the value is not in the proper range; otherwise, Youve entered a correct door number. prints. Assume the input variable for the Scanner class and the door variable are already declared. Use single-selection if statements. HINT: Prompt for the door value at the beginning of the loop.

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

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions

Question

3. Influencing people to willingly follow that direction?

Answered: 1 week ago

Question

What is Working Capital ? Explain its types.

Answered: 1 week ago