Place your order now for a similar assignment and have exceptional work written by our team of experts, At affordable rates
For This or a Similar Paper Click To Order Now
This is the old “I’m thinking of a number between…”. When you run the program, the computer randomly generates a number. Then, the user is to guess the number. Upon guessing wrong, the program gives him/her a hint as to whether the guess is too high or too low. Once the number has been guessed, the game is over.
Create a program to input, keep track of, and check the user’s attempts to guess a randomly generated number. The input portion of the program will be a continuous loop, only breaking out of it when the user either guesses the correct number or by entering -1 to signify giving up. After each guess, the user will be informed of his guess being too high, too low, or exactly correct. Upon exiting the loop, the user is given feedback of their guesses (amount guessed too low, amount guessed too high, the total amount of guesses).
You’ll need to generate a random number to be guessed by the user. Here are some lines of code you’ll need:
#include // loads in the library with the code to generate random numbers
#include // loads in the library with the code to get the current time in seconds
srand(time(NULL)); // sets the seed of the random number the current time in seconds
int value = rand() % 100 + 1; // this is the line of code that grabs the random number itselfAfter the user enters a guess, output a message. For example, “Your guess is larger than the random value. Next guess: “. Or, “You’ve guessed correct!” if the number guessed matches the random number the program generated.
Example of how this program’s output should look after it runs:
run:
Guess the number I’m thinking of, from 1-100: 16
Your guess is larger than the random value. Next guess:
8
Your guess is larger than the random value. Next guess:
4
Your guess is smaller than the random value. Next guess:
6
You’ve guessed correct!
Total number of guesses: 4
Smaller Guesses: 1
Larger Guesses: 2
Break large problems into smaller pieces!
Sometimes it is useful for beginners to complete a smaller, simpler program before tackling the full project. Start with an easy program that only completes part of the project. Name your project ‘project2’. Always use variable and project names that clearly describe what you are creating.
Please Design First
Dividing a larger problem into smaller sub-problems is an important technique in computer programming.
It is a good practice to design your software before you write the code. Here are some design tasks you should complete before you start:
Write out a list of variables you think you will need (e.g. int totalGuesses; // count of many guesses altogether scores)
Flow chart (or Pseudocode) the selection statement(s) to decide if the guess was too high, too low, or the equivalent number
Flow chart (or Pseudocode) the loop, include the check for -1 input and update of variables
In other words, have some idea about HOW you are going to solve the problem BEFORE you try to solve the problem.
OBJECT OF THE GAME (not required):
When you’ve completed this assignment, see if you can beat the game. The object of the game is to discover the algorithm you can use to never exceed 5 wrong guesses. HINT: The object of the game changes to never exceed 7 wrong guesses when you change the random number from 1-32 to 1-128. There is an algorithm in computer science you are looking for.
Something to think about:
How are random numbers generated on a computer?
Why Work with Us
Top Quality and Well-Researched Papers
We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.
Professional and Experienced Academic Writers
We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.
Free Unlimited Revisions
If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.
Prompt Delivery and 100% Money-Back-Guarantee
All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.
Original & Confidential
We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.
24/7 Customer Support
Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.
Try it now!
How it works?
Follow these simple steps to get your paper done
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.
Our Services
No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.
Essays
No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.
Admissions
Admission Essays & Business Writing Help
An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.
Reviews
Editing Support
Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.
Reviews
Revision Support
If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.