Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code a program that allows a contestant to win an all-expenses-paid vacation to the Bahamas.(Java) 1. Prompt the user for the word-of-the-day (make up one).

Code a program that allows a contestant to win an all-expenses-paid vacation to the Bahamas.(Java)

1. Prompt the user for the word-of-the-day (make up one). If the word-of-the-day is entered incorrectly, print the error message "Invalid! Try again! 9 attempt(s) left." where the 9 represents the actual number of attempts left. If the user doesn't enter the correct word-of-the-day in 3 tries using a do/while loop, then the program will exit with the following message "Sorry! You've exhausted all your attempts!"; otherwise, go to number 2 below.

2. Prompt the user for the answer to "3 * 8 = " using a for loop. If the answer is incorrect, print an error message similar to the one above about the number of attempts left. After 3 incorrect answers, the program will exit with an error message that there are no more attempts left (refer to the one above). If the user enters the correct answer, then prompt the user for his/her name and phone number as follows: "Please enter, separated by a return, your first name, last name, and 3-part phone number (area code, prefix and line number without dashes) in a drawing for an all-expenses-paid vacation to the Bahamas: ". Since you are capturing multiple String values, you'll use nextLine().

Print what was captured as:

"Thank you Xxxxxxxxxxx Xxxxxxxxxxx. We'll call you at XXX-XXX-XXXX if you're a winner." where the Xs in the thank you sentence is the first and last name respectively and the Xs in the "call you" sentence is the telephone number.

Code System.exit(0) only once at the end of main(), which means you will have to set the loop-control variables to a value that will forcibly terminate the do/while and for loops if the user entries to the prompts are correct.

You cannot use the break statement.

Hint: You should initialize the loop-control variables for the do/while and for loops to 2 then count down.

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_2

Step: 3

blur-text-image_3

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions

Question

convert 1 0 0 0 0 0 0 0 1 1 0 . 0 1 0 1 binary into hexdecimal

Answered: 1 week ago

Question

Determine the roles of spatial layout and functionality.

Answered: 1 week ago