E Ensign Homepage C D O 19 LDS 28 63F Clear 5.6 Group Lab-Guessing Game X...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
E Ensign Homepage C D O 19 LDS 28 63F Clear 5.6 Group Lab-Guessing Game X ensign.instructure.com/courses/14050/assignments/798611?module_item_id=1612090 FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home Announcements Syllabus Modules X Grades People Tutoring Resources Course Hero X iCloud s byu chat page This diagram provides a rudimentary architecture for the guessing game program: TestOut LabSim + Main() Declare variables like Scanner etc. Game do-while loop Course Hero Primary program do-while loop Describe game. Generate random number. Initialize guessCount etc. Numeric Input Validation do-while loop Get guess from user. If guess is valid number, exit validation loop. guess is not valid, print error. Stay in loop. Increment guessCount. Provide hint if guess is not correct. If guess is correct, print number of tries and exit Game loop. Non-Numeric Input Validation do-while loop Ask user if they want to play again. If user input is valid 'Y' or 'N', exit validation loop. If user input is not valid 'Y' or 'N', print error. Stay in loop. If user input was 'N', exit Primary program loop. a I 7:43 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.6 Group Lab-Guessing Game X ensign.instructure.com/courses/14050/assignments/798611?module_item_id=1612090 Announcements Syllabus Modules Grades People X Tutoring Resources Example Run Course Hero iCloud byu chat page s I'm thinking of a number between 1 and 100. What is your guess? something Invalid Response! Please enter a whole number. What is your guess? 50 Your guess is too high. Try again. What is your guess? 25 Your guess is too low. Try again. This program is a guessing game. The computer will generate a random integer between 1 and 100. The user will try to guess the number. Let's get started! What is your guess? 33 CORRECT! You guessed it in 3 tries!! Would you like to play again? Not sure Invalid Response! Please answer with a 'Y' or 'N'. Would you like to play again? (Y/N): y X TestOut LabSim + Course Hero This program is a guessing game. The computer will generate a random integer between 1 and 100. The user will try to guess the number Let's get started! OneDrive I Screenshot saved The screenshot was added to your OneDrive. 4) D x 7:43 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.6 Group Lab-Guessing Game X ensign.instructure.com/courses/14050/assignments/798611?module_item_id=1612090 Announcements Syllabus Modules Grades People X Tutoring Resources iCloud byu chat page s Invalid Response! Please answer with a 'Y' or 'N' Would you like to play again? (Y/N): y Course Hero I'm thinking of a number between 1 and 100. What is your guess? 50 Your guess is too high. Try again. What is your guess? 25 Your guess is too high. Try again. What is your guess? 12 Your guess is too high. Try again. This program is a guessing game. The computer will generate a random integer between 1 and 100. The user will try to guess the number. Let's get started! What is your guess? 6 Your guess is too high. Try again. What is your guess? 3 Your guess is too low. Try again. X What is your guess? 4 CORRECT! You guessed it in 6 tries!! Would you like to play again? (Y/N): n TestOut LabSim + Course Hero OneDrive I Screenshot saved The screenshot was added to your OneDrive. 4) D x 7:43 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.6 Group Lab-Guessing Game X ensign.instructure.com/courses/14050/assignments/798611?module_item_id=1612090 Announcements Syllabus Modules Grades People X Tutoring Resources Course Hero iCloud s byu chat page Package Name: week5 Class Name: GuessingGame X TestOut LabSim + When submitting this lab, submit a java file called "GuessingGame", and create the following structure in Eclipse: Course Hero For this lab, you'll need to use do-while loops and if statements to construct a guessing game. The computer will choose a random number between 1 and 100, and the user will need to guess what the number is. If the user guesses incorrectly, the computer will indicate whether the user's guess was too high or too low. If the user guesses correctly, the computer reports how many tries it took to get the correct answer, and then asks if the user would like to play again. This program will require four do- while loops: The primary do-while loop (outermost) will contain almost all of the code in the program and keep running over and over until the user indicates they no longer wish to play. The game do-while loop is nested inside the primary do-while loop and will keep running over and over again until the user guesses the correct answer and wins the game. As soon as the user wins a game, the program will exit this do-while loop. The numeric input validation do-while loop is nested inside of the game do-while loop and will ensure that the user entered a valid whole number for each guess. The non-numeric input validation do-while loop is located AFTER and OUTSIDE of the game do-while loop. It is only executed after a game is complete and asks the user if they would like to play again. It is nested inside of the primary do-while loop and will ensure that the user entered a valid 'Y' / 'y' / 'N' / 'n' in answer to the "Would you like to play again (Y/N)?" question. a I 7:43 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.6 Group Lab-Guessing Game X ensign.instructure.com/courses/14050/assignments/798611?module_item_id=1612090 Announcements Syllabus Modules Grades People X Tutoring Resources Course Hero X iCloud is byu chat page TestOut LabSim //Define the range There are several ways to generate random numbers in Java. We will use the method that utilized the Math library. This will require you to include the following line of code at the top of your program, before your Lab4_6 class declaration. import java.lang.Math; The method, Math.random(), will return a random value between 0 (inclusively) and 1.0 (exclusively). In order to modify this to a range between the integers 1 and some upper limit, we need to multiply the return value of Math.random() by the upper limit of the range we desire and add 1. For example, if we wanted to generate a random number between 1 and 50, we would use the code: double randNum = (Math.random() * 50) + 1; If we wanted to limit the result further to only include integer values we would cast the results to ints. int randNum = (int)(Math.random() * 50) + 1; To make this code more useful and specify both an upper limit and a lower limit, we would modify the code as follows: int randNum = (int)(Math.random() * (1034 - 17 + 1)) + 17; or more generically: + int randNum = (int)(Math.random() * (upperLimit - lowerLimit + 1))+ lowerLimit; For example, if we wanted to generate a random number between 17 and 1034, we would use the code: Course Hero a I 7:43 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.6 Group Lab-Guessing Game X ensign.instructure.com/courses/14050/assignments/798611?module_item_id=1612090 Announcements Syllabus Modules Grades People X Tutoring Resources Course Hero int max = 1034; int min = 17; int range = max - min + 1; iCloud s byu chat page TestOut LabSim //Generate a random number between min and max int randNum = (int)(Math.random() * range) + min; X + BIG HINT: When approaching a problem with several nested loops, it is sometimes easier to start with the innermost loops and work outward: Create the numeric input validation loop. Indent the numeric input validation loop and surround it with the game loop. Course Hero Add the non-numeric input validation loop after the game loop. Indent the game loop and the non-numeric input validation loops and surround them with the primary program loop. This diagram provides a rudimentary architecture for the guessing game program: Main() Declare variables like Scanner etc. Primary program do-while loop Describe game. Generate random number. Initialize guessCount etc. a I 7:43 PM 10/11/2022 X : E Ensign Homepage C D O 19 LDS 28 63F Clear 5.6 Group Lab-Guessing Game X ensign.instructure.com/courses/14050/assignments/798611?module_item_id=1612090 FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home Announcements Syllabus Modules X Grades People Tutoring Resources Course Hero X iCloud s byu chat page This diagram provides a rudimentary architecture for the guessing game program: TestOut LabSim + Main() Declare variables like Scanner etc. Game do-while loop Course Hero Primary program do-while loop Describe game. Generate random number. Initialize guessCount etc. Numeric Input Validation do-while loop Get guess from user. If guess is valid number, exit validation loop. guess is not valid, print error. Stay in loop. Increment guessCount. Provide hint if guess is not correct. If guess is correct, print number of tries and exit Game loop. Non-Numeric Input Validation do-while loop Ask user if they want to play again. If user input is valid 'Y' or 'N', exit validation loop. If user input is not valid 'Y' or 'N', print error. Stay in loop. If user input was 'N', exit Primary program loop. a I 7:43 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.6 Group Lab-Guessing Game X ensign.instructure.com/courses/14050/assignments/798611?module_item_id=1612090 Announcements Syllabus Modules Grades People X Tutoring Resources Example Run Course Hero iCloud byu chat page s I'm thinking of a number between 1 and 100. What is your guess? something Invalid Response! Please enter a whole number. What is your guess? 50 Your guess is too high. Try again. What is your guess? 25 Your guess is too low. Try again. This program is a guessing game. The computer will generate a random integer between 1 and 100. The user will try to guess the number. Let's get started! What is your guess? 33 CORRECT! You guessed it in 3 tries!! Would you like to play again? Not sure Invalid Response! Please answer with a 'Y' or 'N'. Would you like to play again? (Y/N): y X TestOut LabSim + Course Hero This program is a guessing game. The computer will generate a random integer between 1 and 100. The user will try to guess the number Let's get started! OneDrive I Screenshot saved The screenshot was added to your OneDrive. 4) D x 7:43 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.6 Group Lab-Guessing Game X ensign.instructure.com/courses/14050/assignments/798611?module_item_id=1612090 Announcements Syllabus Modules Grades People X Tutoring Resources iCloud byu chat page s Invalid Response! Please answer with a 'Y' or 'N' Would you like to play again? (Y/N): y Course Hero I'm thinking of a number between 1 and 100. What is your guess? 50 Your guess is too high. Try again. What is your guess? 25 Your guess is too high. Try again. What is your guess? 12 Your guess is too high. Try again. This program is a guessing game. The computer will generate a random integer between 1 and 100. The user will try to guess the number. Let's get started! What is your guess? 6 Your guess is too high. Try again. What is your guess? 3 Your guess is too low. Try again. X What is your guess? 4 CORRECT! You guessed it in 6 tries!! Would you like to play again? (Y/N): n TestOut LabSim + Course Hero OneDrive I Screenshot saved The screenshot was added to your OneDrive. 4) D x 7:43 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.6 Group Lab-Guessing Game X ensign.instructure.com/courses/14050/assignments/798611?module_item_id=1612090 Announcements Syllabus Modules Grades People X Tutoring Resources Course Hero iCloud s byu chat page Package Name: week5 Class Name: GuessingGame X TestOut LabSim + When submitting this lab, submit a java file called "GuessingGame", and create the following structure in Eclipse: Course Hero For this lab, you'll need to use do-while loops and if statements to construct a guessing game. The computer will choose a random number between 1 and 100, and the user will need to guess what the number is. If the user guesses incorrectly, the computer will indicate whether the user's guess was too high or too low. If the user guesses correctly, the computer reports how many tries it took to get the correct answer, and then asks if the user would like to play again. This program will require four do- while loops: The primary do-while loop (outermost) will contain almost all of the code in the program and keep running over and over until the user indicates they no longer wish to play. The game do-while loop is nested inside the primary do-while loop and will keep running over and over again until the user guesses the correct answer and wins the game. As soon as the user wins a game, the program will exit this do-while loop. The numeric input validation do-while loop is nested inside of the game do-while loop and will ensure that the user entered a valid whole number for each guess. The non-numeric input validation do-while loop is located AFTER and OUTSIDE of the game do-while loop. It is only executed after a game is complete and asks the user if they would like to play again. It is nested inside of the primary do-while loop and will ensure that the user entered a valid 'Y' / 'y' / 'N' / 'n' in answer to the "Would you like to play again (Y/N)?" question. a I 7:43 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.6 Group Lab-Guessing Game X ensign.instructure.com/courses/14050/assignments/798611?module_item_id=1612090 Announcements Syllabus Modules Grades People X Tutoring Resources Course Hero X iCloud is byu chat page TestOut LabSim //Define the range There are several ways to generate random numbers in Java. We will use the method that utilized the Math library. This will require you to include the following line of code at the top of your program, before your Lab4_6 class declaration. import java.lang.Math; The method, Math.random(), will return a random value between 0 (inclusively) and 1.0 (exclusively). In order to modify this to a range between the integers 1 and some upper limit, we need to multiply the return value of Math.random() by the upper limit of the range we desire and add 1. For example, if we wanted to generate a random number between 1 and 50, we would use the code: double randNum = (Math.random() * 50) + 1; If we wanted to limit the result further to only include integer values we would cast the results to ints. int randNum = (int)(Math.random() * 50) + 1; To make this code more useful and specify both an upper limit and a lower limit, we would modify the code as follows: int randNum = (int)(Math.random() * (1034 - 17 + 1)) + 17; or more generically: + int randNum = (int)(Math.random() * (upperLimit - lowerLimit + 1))+ lowerLimit; For example, if we wanted to generate a random number between 17 and 1034, we would use the code: Course Hero a I 7:43 PM 10/11/2022 X : E Ensign Homepage C D Q & O 19 LDS 28 63F Clear FAFSA Student Loan ck Credit Karma M Gmail 2022 Fall Semester Home 5.6 Group Lab-Guessing Game X ensign.instructure.com/courses/14050/assignments/798611?module_item_id=1612090 Announcements Syllabus Modules Grades People X Tutoring Resources Course Hero int max = 1034; int min = 17; int range = max - min + 1; iCloud s byu chat page TestOut LabSim //Generate a random number between min and max int randNum = (int)(Math.random() * range) + min; X + BIG HINT: When approaching a problem with several nested loops, it is sometimes easier to start with the innermost loops and work outward: Create the numeric input validation loop. Indent the numeric input validation loop and surround it with the game loop. Course Hero Add the non-numeric input validation loop after the game loop. Indent the game loop and the non-numeric input validation loops and surround them with the primary program loop. This diagram provides a rudimentary architecture for the guessing game program: Main() Declare variables like Scanner etc. Primary program do-while loop Describe game. Generate random number. Initialize guessCount etc. a I 7:43 PM 10/11/2022 X :
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
HR Trends Institute https://hrtrendinstitute.com/(Links to an external site.) HR Technology Discuss IT changes that you have experienced at work such as new cash register or inventory system or...
-
Two people each pull with a force of 300 N on a rope in a tug-of-war. What is the net force on the rope? How much force is exerted on each person by the rope?
-
Solve the given systems of equations by determinants. 4u 4v 2w = -4 + - 20u15v 24u 12v + 10w = -10 9w 39
-
Explain several implications of IFRS on financial reporting by health care organizations.
-
Natalia Wallace is the new controller for Smart Software, Inc., which develops and sells education software. Shortly before the December 31 fiscal year-end, James Cauvet, the company president, asks...
-
(d) What is the value of "j" after the execution of the partial code in Figure 4.2? Explain your answer. int j = 10; for (int i = 0; 0; i
-
There is a slide in a park. One of its side Company hired one of its walls for 3 months.walls has been painted in some colour with a message ?KEEP THE PARK GREEN AND CLEAN? (see figure). If the sides...
-
The molecular orbitals for the allyl system (bases set = three conjugated p orbitals) are given by: 1: 1/2 1 + 1/2(2 2) + 1/2 p3. 3: 1/2 1 1/2(2 $2) + 1/2 63. 2: 1/2(2 01) - 1/2(2 $3); note that c2 =...
-
How is deviance the same in the physical world and digital online world? How it is different?
-
A company, which is debt-free and finances only with equity from retained earnings, is considering 7 equal-sized capital budgeting projects. Its CFO hired you to assist in deciding whether none,...
-
What is the output of the following C++ segment of code: for(; ;) { Cout < >x; If (x%2==0) continue; If (x %3==0) break; Cout <
-
In which phase of the emulsion is oleic acid found for the BP formula? Support your conclusion by referencing the relevant results. What role in the emulsion do oleic acid and dilute ammonia solution...
-
Q.2 (a) What is the difference between web designing and Web development ? Write atleast three latest programming language/tools used for each. (b) When surfing online, how can you determine if the...
-
The production budget of Artest Company calls for 80,000 units to be produced. If it takes 30 minutes to make one unit and the direct labor rate is $16 per hour, what is the total budgeted direct...
-
Larry Gaines, age 42, sells his personal residence on November 12, 2012, for $144,000. He lived in the house for 7 years. The expenses of the sale are $10,500, and he has made capital improvements of...
-
Brian and Kim have a 12-year-old child, Stan. For 2012, Brian and Kim have taxable income of $52,000, and Stan has nonqualifying dividend income of $4,500 and investment expenses of $250. No election...
-
How much of each of the following prizes or awards is taxable? a. Cheline received a $50,000 gift bag at the Oscars in 2012. b. Jon received a gold watch worth $350 for 25 years of service to his...
-
You need to understand the approach described in question 3 in More Genetic TIPS before answering this question. A gene that is normally expressed in pancreatic cells was cloned and then subjected to...
-
Many researchers are interested in the transcription of protein-encoding genes in eukaryotes. Such researchers want to study mRNA. One method that is used to isolate mRNA is column chromatography....
-
The type of model building used by Pauling and by Watson and Crick involved the use of ball-and-stick units. Model building can now be done with computer software. Even though you may not be familiar...
Study smarter with the SolutionInn App