Guessing game | CIS 1502 | Florida Institute of Technology

Guessing game | CIS 1502 | Florida Institute of Technology

 
The programming assignment for the final week, due on the final day of the course, if not before, has been modified in an attempt to allow for more creativity in the coding process.  An outline of the new assignment will follow as I do not have the ability to modify the template of the course.  I’d begin looking at it now and ask questions as you move forward. 
Programming Assignment #3 (25 points) *modified at the end*
This assignment will give you practice with while loops and pseudorandom numbers. You aregoing to write a program that allows the user to play a simple game in which your program thinksup an integer and allows the user to try to determine the number with a minimum number of tries.For each incorrect try you will tell the user whether the right answer is higher or lower. Yourprogram is required to exactly reproduce the format and behavior of the log of execution at the endof this write-up, so you may want to look that over first.
At a minimum, your program should have the following static methods in addition to methodmain:a method to give instructions to the user
a method to report overall results to the user
You may define more methods than this if you find it helpful, although you will find that thelimitation that methods can return only one value will tend to limit how much you candecompose this problem.
You are to define a class constant for the maximum number used in the game. The sample belowselects a number from 1 to 100, but the choice of 100 is arbitrary. By introducing a constant for100, you should be able to change just the value of the constant to make the program play thegame with a range of 1 to 50 or a range of 1 to 250 or some other range starting with 1.
When you ask the user whether or not to play again, you should use the “next()” method of theScanner class to read a one-word answer from the user. You should continue playing if thisanswer begins with the letter “y” or the letter “Y”. Notice that the user is allowed to type wordslike “yes”. You are to look just at the first letter of the user’s response and see whether it beginswith a “y” or “n” (either capitalized or not) to determine whether to play again.
Assume that the user always types an integer when trying, that the integer is always in anappropriate range and that the user gives you a one-word answer beginning with “y”, “Y”, “n” or“N” when asked whether to play again.
You will notice at the end of the log that you are to report various statistics about the series ofgames played by the user. You are to report the total number of games played, the total number oftries made (all games included), the average number of tries per game and the maximum numberof tries used in any single game. You should also report the user’s best game(s) indicating whichgame(s) had the minimum number of tries and what that minimum was.
Here are a few helpful hints to keep in mind:
this program needs to generate pseudorandom numbers
To deal with the yes/no response from the user, you might want to use some of the String classmethods. You will want to use the next() method of the Scanner class to read a word from theconsole.
Because this program uses pseudorandom numbers you won’t be able to recreate this exactlog. The key requirement is that you reproduce the format of this log and that your calculationsfor overall statistics are correct for your log.
It’s a good idea to change the value of your class constant and run the program to make surethat everything works right with the new value of the constant. For example, turn it into agame for numbers between 1 and 5.
This program is more difficult than most to decompose into methods, so you may end up havingmethods that are longer than 15 lines. You are required to have a while loop in main that playsmultiple games and prompts the user for whether or not to play another game. You shouldn’thave all the code in main because you are required to have the methods described at thebeginning of this write-up.
You are expected to make appropriate choices about when to store values as int versus double,which if/else constructs to use, what parameters to pass, and so on.
Your program should be stored in a file called Guess.java.
Include a comment at the beginning of your program with basic information and a description ofthe program. This includes having an adequate comment header, commenting every line, and theintegrity statement.   The integrity statement must be included or the max score will be cut in half.
Turn in your screenshot in Word of the output with filenameJonBrownCIS1501ScreenShotsProgrammingAssignment3Jan122017 (your name, the coursename, the content of the file, and the date), Guess.java and Guess.class (Please make sure toname your files exactly, including identical capitalization.) Then put all three files in one zip file.The zip file should be named: your name, the course name, the content of the file, and the dateand then submit to the Assignments link on the course web page.
Log of execution (user input underlined)
This program allows you to play a game.I will think of a number between 1 and 100and will allow you to try to determine it.
For each try, I will tell you whether theright answer is higher or lower than yourtry.I’m thinking of a number…
Your try? 20higher
Your try? 40higher
Your try? 60higher
Your try? 80higher
Your try? 100lower
Your try? 90lower
Your try? 88lower
Your try? 86
Game #1: You got it right in 8 tries
Do you want to play again? YesI’m thinking of a number…
Your try? 20higher
Your try? 40higher
Your try? 60higher
Your try? 80higher
Your try? 82higher
Your try? 84higher
Your try? 86higher
Your try? 88higher
Your try? 90higher
Your try? 92higher
Your try? 94lower
Your try? 93
Game #2: You got it right in 12 triesDo you want to play again? YESI’m thinking of a number…
Your try? 20higher
Your try? 40higher
Your try? 60lower
Your try? 58lower
Your try? 56
Game #3: You got it right in 5 triesDo you want to play again? NoOverall results:
total games = 3total tries = 25
tries/game = 8.333333333333334max tries = 12
Your best game was Game#3 in 5 tries
Here are the modifications for this term.

user must play at least 3 games and no more than 5
you must ask the user how many games they wish to play right from the start; if they say less than 3 or more than 5, you must prompt them again, this time with instructions on the limits
now you must capture the maximum value for each game offering a choice of 50, 100, 200 or 500 (other entries are not allowed)
you must keep track of the number of guesses AND accumulate how far off each guess was from the given number (25 is 10 off from 35 and so is 45 (no negative values))

Sample output:
Let’s play a number guessing game.
How many games do you want to play?
6
I’m sorry.  We must play between 3 and 5 games.
How many do you want to play?
3
For these 3 games, what is the range of numbers we are going to use?  1 to __?
75
Acceptable answers are 50, 100, 200 or 500.  Please respond:
100
Good luck!
Game 1:
This program allows you to play a game.I will think of a number between 1 and 100 <- display the user’s entered range maxand will allow you to try to determine it.
For each try, I will tell you whether theright answer is higher or lower than yourtry.I’m thinking of a number…
(back and forth until the user gets the correct answer)
Your try? 20higher
Your try? 40higher
Your try? 60higher
Your try? 80higher
Your try? 82higher
Game 1:
You got it right 5 guesses.
You were off by an average of 25.6 per guess.
(note: the answer was 82 and the guesses were off by 62, 42, 22, 2 and 0 which total 128/5 guesses = 25.6) **don’t print this
Good luck!
Game 2 begins now:
repeat the process
reset (or renew?) the counter for the number of tries/guesses
reset (or renew?) the counter for tracking the average amount off
Game 2:
output for the # of guesses and the off by an average of
repeat the process for the 3rd game and possibly the 4th and the 5th
output as well
For the final output:
Your best game in terms of lowest guesses was Game # (insert the number of the game with the least number of guesses) when you solved the game in ___ guesses.
Your best game in terms of closest guesses was Game # (insert the number of the game with the lowest average “off guess”) when you were off by an average of ___.
IF the #s of the best games match, the user should receive some special message from you.  For example, if your best game in terms of lowest guesses and closest guesses was, let’s say game #2, the user should see some sort of special message noting how well game #2 was played.

ad:  Delta 8 online | THC Online | Buy hemp online | THC Carts | Delta 8 Carts | THCO Carts | HQD Vape | Fume Vape | Fume Extra | Fume Unlimited | HQD Cuvie | HQD Cuvie plus | zero Nic Disposable Vapes | Fume Infinity | Fume Ultra | FoodGod | Supreme Vape 

 
The programming assignment for the final week, due on the final day of the course, if not before, has been modified in an attempt to allow for more creativity in the coding process.  An outline of the new assignment will follow as I do not have the ability to modify the template of the course.  I’d begin looking at it now and ask questions as you move forward. 
Programming Assignment #3 (25 points) *modified at the end*
This assignment will give you practice with while loops and pseudorandom numbers. You aregoing to write a program that allows the user to play a simple game in which your program thinksup an integer and allows the user to try to determine the number with a minimum number of tries.For each incorrect try you will tell the user whether the right answer is higher or lower. Yourprogram is required to exactly reproduce the format and behavior of the log of execution at the endof this write-up, so you may want to look that over first.
At a minimum, your program should have the following static methods in addition to methodmain:a method to give instructions to the user
a method to report overall results to the user
You may define more methods than this if you find it helpful, although you will find that thelimitation that methods can return only one value will tend to limit how much you candecompose this problem.
You are to define a class constant for the maximum number used in the game. The sample belowselects a number from 1 to 100, but the choice of 100 is arbitrary. By introducing a constant for100, you should be able to change just the value of the constant to make the program play thegame with a range of 1 to 50 or a range of 1 to 250 or some other range starting with 1.
When you ask the user whether or not to play again, you should use the “next()” method of theScanner class to read a one-word answer from the user. You should continue playing if thisanswer begins with the letter “y” or the letter “Y”. Notice that the user is allowed to type wordslike “yes”. You are to look just at the first letter of the user’s response and see whether it beginswith a “y” or “n” (either capitalized or not) to determine whether to play again.
Assume that the user always types an integer when trying, that the integer is always in anappropriate range and that the user gives you a one-word answer beginning with “y”, “Y”, “n” or“N” when asked whether to play again.
You will notice at the end of the log that you are to report various statistics about the series ofgames played by the user. You are to report the total number of games played, the total number oftries made (all games included), the average number of tries per game and the maximum numberof tries used in any single game. You should also report the user’s best game(s) indicating whichgame(s) had the minimum number of tries and what that minimum was.
Here are a few helpful hints to keep in mind:
this program needs to generate pseudorandom numbers
To deal with the yes/no response from the user, you might want to use some of the String classmethods. You will want to use the next() method of the Scanner class to read a word from theconsole.
Because this program uses pseudorandom numbers you won’t be able to recreate this exactlog. The key requirement is that you reproduce the format of this log and that your calculationsfor overall statistics are correct for your log.
It’s a good idea to change the value of your class constant and run the program to make surethat everything works right with the new value of the constant. For example, turn it into agame for numbers between 1 and 5.
This program is more difficult than most to decompose into methods, so you may end up havingmethods that are longer than 15 lines. You are required to have a while loop in main that playsmultiple games and prompts the user for whether or not to play another game. You shouldn’thave all the code in main because you are required to have the methods described at thebeginning of this write-up.
You are expected to make appropriate choices about when to store values as int versus double,which if/else constructs to use, what parameters to pass, and so on.
Your program should be stored in a file called Guess.java.
Include a comment at the beginning of your program with basic information and a description ofthe program. This includes having an adequate comment header, commenting every line, and theintegrity statement.   The integrity statement must be included or the max score will be cut in half.
Turn in your screenshot in Word of the output with filenameJonBrownCIS1501ScreenShotsProgrammingAssignment3Jan122017 (your name, the coursename, the content of the file, and the date), Guess.java and Guess.class (Please make sure toname your files exactly, including identical capitalization.) Then put all three files in one zip file.The zip file should be named: your name, the course name, the content of the file, and the dateand then submit to the Assignments link on the course web page.
Log of execution (user input underlined)
This program allows you to play a game.I will think of a number between 1 and 100and will allow you to try to determine it.
For each try, I will tell you whether theright answer is higher or lower than yourtry.I’m thinking of a number…
Your try? 20higher
Your try? 40higher
Your try? 60higher
Your try? 80higher
Your try? 100lower
Your try? 90lower
Your try? 88lower
Your try? 86
Game #1: You got it right in 8 tries
Do you want to play again? YesI’m thinking of a number…
Your try? 20higher
Your try? 40higher
Your try? 60higher
Your try? 80higher
Your try? 82higher
Your try? 84higher
Your try? 86higher
Your try? 88higher
Your try? 90higher
Your try? 92higher
Your try? 94lower
Your try? 93
Game #2: You got it right in 12 triesDo you want to play again? YESI’m thinking of a number…
Your try? 20higher
Your try? 40higher
Your try? 60lower
Your try? 58lower
Your try? 56
Game #3: You got it right in 5 triesDo you want to play again? NoOverall results:
total games = 3total tries = 25
tries/game = 8.333333333333334max tries = 12
Your best game was Game#3 in 5 tries
Here are the modifications for this term.

user must play at least 3 games and no more than 5
you must ask the user how many games they wish to play right from the start; if they say less than 3 or more than 5, you must prompt them again, this time with instructions on the limits
now you must capture the maximum value for each game offering a choice of 50, 100, 200 or 500 (other entries are not allowed)
you must keep track of the number of guesses AND accumulate how far off each guess was from the given number (25 is 10 off from 35 and so is 45 (no negative values))

Sample output:
Let’s play a number guessing game.
How many games do you want to play?
6
I’m sorry.  We must play between 3 and 5 games.
How many do you want to play?
3
For these 3 games, what is the range of numbers we are going to use?  1 to __?
75
Acceptable answers are 50, 100, 200 or 500.  Please respond:
100
Good luck!
Game 1:
This program allows you to play a game.I will think of a number between 1 and 100 <- display the user’s entered range maxand will allow you to try to determine it.
For each try, I will tell you whether theright answer is higher or lower than yourtry.I’m thinking of a number…
(back and forth until the user gets the correct answer)
Your try? 20higher
Your try? 40higher
Your try? 60higher
Your try? 80higher
Your try? 82higher
Game 1:
You got it right 5 guesses.
You were off by an average of 25.6 per guess.
(note: the answer was 82 and the guesses were off by 62, 42, 22, 2 and 0 which total 128/5 guesses = 25.6) **don’t print this
Good luck!
Game 2 begins now:
repeat the process
reset (or renew?) the counter for the number of tries/guesses
reset (or renew?) the counter for tracking the average amount off
Game 2:
output for the # of guesses and the off by an average of
repeat the process for the 3rd game and possibly the 4th and the 5th
output as well
For the final output:
Your best game in terms of lowest guesses was Game # (insert the number of the game with the least number of guesses) when you solved the game in ___ guesses.
Your best game in terms of closest guesses was Game # (insert the number of the game with the lowest average “off guess”) when you were off by an average of ___.
IF the #s of the best games match, the user should receive some special message from you.  For example, if your best game in terms of lowest guesses and closest guesses was, let’s say game #2, the user should see some sort of special message noting how well game #2 was played.

Guessing game | CIS 1502 | Florida Institute of Technology