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