This assignment is due by Tuesday, July 17, 2018, 11:59 PM. · Instructions · Rubric · Submission ·
This assignment exercises your ability
to use loops and functions, and provides more experience with asking the computer to
generate a pseudo-random number.
Instructions
Your goal for this assignment is to exercise your knowledge of
selection statements (
if
/
else
), looping constructs (
while
and
for
) and the use of rand(). Your game must adhere to the
following interaction example.
Hold onto your pants, we're about to play guess-the-numbah! Pick
a number between 0 and 100: 20 Too low! Not even close!
Pick a number between 0 and 100: 75 Too high! Pick a number
between 0 and 100: 63 Too low! Oooh you're close! Pick a
number between 0 and 100: 64 That's right! You won the game in 4
tries.
Your game must use a random number between 0 and 100,
inclusively. You should only accept guesses that are within the range [0,
100], showing an error message otherwise. Your game
must print "Too low!" or "Too high!" relative to the target number and
the players' guess. Your game must print "Oooh you're close!" if
the number guessed differs from the target by 5 or less; and it
must print "Not even close!" if the number guessed differs from the
target by a value of 25 or more.
For example, if the target is 50 and the player enters 10, your program
should print "Too low!" and "Not even close!", but if the player enters
52, your program should print "Too high!" and "Oooh you're close!".
When the correct number is guessed, your program must print "You won
the game in N tries" where N is the number of valid guesses
the player made.
Functional Requirements
- Define appropriate constants for the LOW (=0) and
HIGH (=100) limits of the game. Use these constants correctly.
- Also, define appropriate constants for the
TOO_CLOSE_DIFFERENCE (=5) and TOO_HIGH_DIFFERENCE (=25) values. Use these constants correctly.
- The code should be structured similarly to Lab4B. We'll want functions to
accomplish the following tasks (at a minimum):
- Generate a random number between min and max vales
- Check if the user's guess is valid
- Check if user's guess is correct and print the corresponding message
We'll need to make sure there are at least three functions being used. It is perfectly acceptable
to create additional functions as needed.
Grading RubricYour submission will be graded according to the following rubric.
2 |
All code submitted properly. |
4 |
All labs completed and submitted |
6 |
Game is properly playable. |
8 |
Functional requirements above met. |
2 |
Game is properly randomized. |
2 |
(1) Comments used (2) Coding style followed (3) Appropriate variable names, constants, and data types used (4) Instructions followed |
This assignment is due by Tuesday, July 17, 2018, 11:59 PM. SubmissionAlways, always, ALWAYS update the header comments at the top of your main.cpp file. And if you ever get stuck, remember that there is LOTS of help available. The following instructions are copied from How to Submit Homework.
It is critical that you follow these steps when submitting homework.
If you do not follow these instructions, your assignment
will receive a major deduction. Why all the fuss? Because we have
several hundred of these assignments to grade, and we use
computer tools to automate as much of the process as possible.
If you deviate from these instructions, our grading tools will
not work. And that makes us very unhappy. And when we're
unhappy, we give penalties. Thus, make us happy.
Submission Instructions
Here are step-by-step instructions for submitting your homework properly:
- File and folder names are extremely important in this process.
Please double-check carefully, to ensure things are named correctly.
- The top-level folder of your project must be named
Set4
- Inside
Set4 , create 3 sub-folders that are required for this Set. The name of each sub-folder is defined in that Set (e.g. L4A , L4B , and A4 ). - Copy your program
main.cpp and supporting files into the subdirectories of
Set4 (steps 1-2),
zip this Set4 folder (steps 3-4), and then submit the zipped file (steps 5-11) to Canvas.
- For example, when you zip/submit
Set4 , there will be 3 sub-folders called L4A , L4B , and A4 inside the Set4 folder, and each of these sub-folders will have a file called main.cpp and nothing else.
- You will need to download each project file(s) from Codenvy to your computer.
- Using Windows Explorer (not to be confused with Internet Explorer), find the file
named
"main.cpp" located inside the folder for the particular lab or homework
assignment you will submit.
STOP: Are you really sure you are viewing the correct assignment's folder?
- Now, for A4, right click on the
main.cpp to copy the file. Then, return to the Set4/A4
folder and right click to paste the file. In other words, put a copy of your homework's main.cpp source code and supporting files into the Set4/A4 folder.
Follow the same steps for L4A, to put a copy of your lab's main.cpp and supporting files into the Set4/L4A folder. Repeat this process for Set4/L4B . STOP: Are you sure your Set4 folder now has all your code to submit?
- Now, right-click on the
"Set4" folder.
- In the pop-up menu that opens, move the mouse
"Send to..." and expand the sub-menu.
- In the sub-menu that opens, select
"Compressed (zipped) folder" .
STOP: Are you really sure you are zipping a Set4 folder with sub-folders that each contain a main.cpp file in it?
- After the previous step, you should now see a
"Set4.zip" file.
- Now visit the Canvas page for this course
and click the
"Assignments" button in the sidebar.
- Find Set4, click on it, find the
"Attach file" area, and then click the "Browse My Computer" button.
- Find the
"Set4.zip" file created earlier and click the "Open" button.
STOP: Are you really sure you are selecting the right homework assignment? Are you double-sure?
- WAIT! There's one more super-important step. Click on the blue
"Submit" button to submit your homework.
- No, really, make sure you click the
"Submit" button to actually submit your homework. Clicking
the "Open" button in the previous step kind of makes it feel like you're done, but you must click
the Submit button as well! And you must allow the file time to upload before you turn off your computer!
- Canvas should say "This assignment is complete. Click OK to review the results.". Click "OK" and view the
files within the zip file you submitted. In other words, verify you submitted what you think you submitted!
In summary, you must zip the "Set4" folder
and only the "Set4" folder, this zip folder must have several sub-folders, you must name all these folders correctly, you must submit the correct zip file for this
homework, and you must click the "Submit" button. Not doing these steps is like bringing your
homework to class but forgetting to hand it in. No concessions will be made for
incorrectly submitted work. If you incorrectly submit your homework, we will not be able to
give you full credit. And that makes us unhappy.
This assignment is due by Tuesday, July 17, 2018, 11:59 PM. |