Requirements: a) Your class should be named NumberGuessingGame, and your source code file should be NumberGuessingGame.java....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Requirements: a) Your class should be named NumberGuessingGame, and your source code file should be NumberGuessingGame.java. named b) Although you don't need to submit a pseudocode for this HW, it is always helpful to start your Java file with a pseudocode writing, that provides the program structure and blocks, and some single-line comments for the major tasks. c) Think: Obviously in most cases, a player will take multiple guesses in this game, thus it needs a loop. So think: What is the condition to continue/ stop the loop? How to make the comparison expression for it? • Which of the three types of repetition, while, do-while, or for, will fit the best in this question? d) Please note that we still need to show and record the attempts with a variable, so we can report it at the end of the game. But this is not used as a loop control counter. Programming styles are always required. e) 1.b Write a Java program for this number guessing game. (9 pts) Execution example: --jGRASP exec: java NumberGuessingGame I got a number in my mind. It is an integer between 0 to 99. Can you guess it out using as less attempt as you can? Attempt # 1: 50 Your guess is too small! Try again! Attempt #2: 75 Your guess is too large! Try again! Attempt # 3: 62 Your guess is too large! Try again! Attempt #4: 56 Your guess is too large! Try again! Attempt # 5: 53 Your guess is too large! Try again! Attempt #6: 51 Your guess is too small! Try again! Attempt # 7: 52 You got it! Congratulations! It took you 7 attempts to guess it out. HW 5 Sentinel Controlled Repetition In this homework, we will develop a number guessing game. Your program will generate a secret number, which is an integer number in the range of 0-99. A player will be asked to guess what is this number, and see how many times it takes for a player to guess it out. Here is the direction for playing this game: 1. When a player starts the game, a secret (integer) number will be determined by computer in the range of 0 - 99. 2. The computer will display a message to the player: "I got a number in my mind (in the range of 0 -99). Guess what it is!" 3. The player will take a guess and enter the guess into the game. If the guess is incorrect, depending on the guessed value, the game will hint the player: "Your guess is too large!" or "Your guess is too small!" Then it will offer to the player: "Try again!" and the player can guess again. 4. This guessing process will be repeated until the player guesses out the number (i.e., their guess is correct). Then the game will say "Congratulations! You got it!" 5. At the end, the game will display the output "You guessed out this number in x attempts. Thanks for playing!" It shows the number of guesses it took for this player to get the secret number. 1.a Develop a flow chart for this problem. (7 pts) Hint: The challenge in this problem is to figure out what is the control to stop the guessing process. The player can guess multiple times, which of course will be a repetition structure. But the game will only stop when the player guesses the number out, (i.e., the player's guess - the secret number). Suggestion: You can start from a simple version of flowchart. It may take a few rounds of modification to get a good one. Lay out the tasks/ rectangles for one guess first. Then make it a repetition and add how you control the repetition. Use correct shapes and symbols - circle for start and end, rectangles for tasks, diamonds for conditions, and arrows to show the sequence. You can use hand drawing, Word, Visio or Raptor in your preference. Make sure the submission is a screenshot picture, PPT file or a PDF. If you create the flowchart using MS Word, you are recommended to save it to PDF for submission, to make sure the shapes and connections won't be altered in the submission. Requirements: a) Your class should be named NumberGuessingGame, and your source code file should be NumberGuessingGame.java. named b) Although you don't need to submit a pseudocode for this HW, it is always helpful to start your Java file with a pseudocode writing, that provides the program structure and blocks, and some single-line comments for the major tasks. c) Think: Obviously in most cases, a player will take multiple guesses in this game, thus it needs a loop. So think: What is the condition to continue/ stop the loop? How to make the comparison expression for it? • Which of the three types of repetition, while, do-while, or for, will fit the best in this question? d) Please note that we still need to show and record the attempts with a variable, so we can report it at the end of the game. But this is not used as a loop control counter. Programming styles are always required. e) 1.b Write a Java program for this number guessing game. (9 pts) Execution example: --jGRASP exec: java NumberGuessingGame I got a number in my mind. It is an integer between 0 to 99. Can you guess it out using as less attempt as you can? Attempt # 1: 50 Your guess is too small! Try again! Attempt #2: 75 Your guess is too large! Try again! Attempt # 3: 62 Your guess is too large! Try again! Attempt #4: 56 Your guess is too large! Try again! Attempt # 5: 53 Your guess is too large! Try again! Attempt #6: 51 Your guess is too small! Try again! Attempt # 7: 52 You got it! Congratulations! It took you 7 attempts to guess it out. HW 5 Sentinel Controlled Repetition In this homework, we will develop a number guessing game. Your program will generate a secret number, which is an integer number in the range of 0-99. A player will be asked to guess what is this number, and see how many times it takes for a player to guess it out. Here is the direction for playing this game: 1. When a player starts the game, a secret (integer) number will be determined by computer in the range of 0 - 99. 2. The computer will display a message to the player: "I got a number in my mind (in the range of 0 -99). Guess what it is!" 3. The player will take a guess and enter the guess into the game. If the guess is incorrect, depending on the guessed value, the game will hint the player: "Your guess is too large!" or "Your guess is too small!" Then it will offer to the player: "Try again!" and the player can guess again. 4. This guessing process will be repeated until the player guesses out the number (i.e., their guess is correct). Then the game will say "Congratulations! You got it!" 5. At the end, the game will display the output "You guessed out this number in x attempts. Thanks for playing!" It shows the number of guesses it took for this player to get the secret number. 1.a Develop a flow chart for this problem. (7 pts) Hint: The challenge in this problem is to figure out what is the control to stop the guessing process. The player can guess multiple times, which of course will be a repetition structure. But the game will only stop when the player guesses the number out, (i.e., the player's guess - the secret number). Suggestion: You can start from a simple version of flowchart. It may take a few rounds of modification to get a good one. Lay out the tasks/ rectangles for one guess first. Then make it a repetition and add how you control the repetition. Use correct shapes and symbols - circle for start and end, rectangles for tasks, diamonds for conditions, and arrows to show the sequence. You can use hand drawing, Word, Visio or Raptor in your preference. Make sure the submission is a screenshot picture, PPT file or a PDF. If you create the flowchart using MS Word, you are recommended to save it to PDF for submission, to make sure the shapes and connections won't be altered in the submission.
Expert Answer:
Answer rating: 100% (QA)
The Java program for the Number Guessing Game along with a simple pseudocode and a description of th... View the full 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
-
You are given the following data set: -[4-[] = You would like to use PCA to find a 1-dimensional representation of the data. a. Plot the data set. b. Compute the feature covariance matrix S. c. You...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Read the case study "Southwest Airlines," found in Part 2 of your textbook. Review the "Guide to Case Analysis" found on pp. CA1 - CA11 of your textbook. (This guide follows the last case in the...
-
The LEGO company is a perfect example of planning. They carefully crafted the name from two phrases into one word. Besides the name, they also planned how they would make the bricks fit into one...
-
Draw the shear and moment diagrams for the beam. Units Used: kN = 103 N Given: F = 7 kN M = 12 kN m a = 2 m b = 2 m c = 4 m
-
Due to its experience rating, Ianelli, Inc., is required to pay unemployment taxes on its payroll as follows: 1. Under SUTA for Massachusetts on taxable payroll of $17,700, the contribution rate is...
-
Consider the National Football League data in Table B.1. a. Fit a multiple linear regression model relating the number of games won to the team's passing yardage $\left(x_{2} ight)$, the percentage...
-
Three different plans for financing a $60,000,000 corporation are under consideration by its organizers. Under each of the following plans, the securities will be issued at their par or face amount,...
-
16 ! Required information 2.77 points eBook Print References [The following information applies to the questions displayed below.] Chuck Wagon Grills, Incorporated, makes a single product-a handmade...
-
The Analytical Chemistry (Dec. 15, 2009) study in which HPLC scientists used high-performance liquid chromatography to determine the amount of drug in a tablet. Twenty-five tablets were produced at...
-
After World War Two, Norway carried out its last executions, mostly of Nazi collaborators. What are those executions thought of by Norwegians? What are their opinions of the death penalty in America?...
-
Describe three paths for implementing the strategy of Hedge Fund A. After a significant amount of internal discussion, Wallace concludes that the pension fund should invest in either Hedge Fund B or...
-
Nowackis most appropriate response to Knights question about the quantitative investment process is to: A. backtest the new strategy. B. define the market opportunity. C. identify the factors to...
-
Which investment approach is the most likely basis for Sardars buy recommendation for AZ Industrial? A. Relative value B. High-quality value C. Deep-value investing Jack Dewey is managing partner of...
-
Based on Exhibit 1, which stock pair should Knight recommend as the best candidate for statistical arbitrage? A. Stock 1 and Stock 2 B. Stock 3 and Stock 4 C. Stock 5 and Stock 6 Aleksy Nowacki is a...
-
Nowackis calculated price/book ratios (P/Bs) and price/earnings ratios (P/Es), in his backtesting of the new strategy, are a problem because of: A. data mining. B. look-ahead bias. C. survivorship...
-
Discuss the continuity at defined as: a) f(z) = Rez 1+1 | at 2=0 of the functions which are b) f(z)= Rez, offic) - (Reza) ) 2 for all z to, and which are equal and which are equal to zere at 2=0
-
What are bounds and what do companies do with them?
-
The following additional information is available for the Dr. Ivan and Irene Incisor family. The Incisors own a rental beach house in Hawaii. The beach house was rented for the full year during 2012...
-
Greg died on July 1, 2012, and left Lea, his wife, a $50,000 life insurance policy which she elects to receive at $5,000 per year plus interest for 10 years. In the current year, Lea receives $6,200....
-
Cypress Corporation has regular taxable income of $170,000 (assume annual gross receipts are greater than $5 million) and regular tax liability of $49,550 for 2012. The corporation also has tax...
-
Th e quick ratio for Company A is closest to: A . 0.43. B . 0.57. C . 1.00.
-
Based on Exhibit 1, the fi nancial leverage ratio for Company B is closest to: A . 0.55. B . 1.22. C . 2.22. EXHIBIT 1 Common-Size Balance Sheets for Company A, Company B, and Sector Average Company...
-
Based on Exhibit 1, which ratio indicates lower liquidity risk for Company A compared with Company B? A . Cash ratio. B . Quick ratio. C . Current ratio. EXHIBIT 1 Common-Size Balance Sheets for...
Study smarter with the SolutionInn App