WSQ06 – Pick a Number

What to Do

https://www.flickr.com/photos/dasprid/8147975983/

https://www.flickr.com/photos/dasprid/8147975983/

Write a program that picks a random integer in the range of 1 to 100.

There are different ways to make that happen, you choose which one works best for you.

It then prompts the user for a guess of the value, with hints of ’too high’ or ’too low’ from the program.

The program continues to run until the user guesses the integer. You could do something extra here including telling there user how many guesses they had to make to get the right answer.

You might want to check that your program doesn’t always use the same random number is chosen and you should also split your problem solving into parts. Perhaps only generate the random number and print that as a first step.

Example Run

I have a number chosen between 1 and 100.
Please guess a number between 1 and 100:  50
I’m sorry but 50 is too high, try again: 25
I’m sorry but 25 is too low, try again: 42
You got it! The right answer is indeed 42.
You made 3 guesses to get the right number.

What to Submit

As usual, create a blog post explaining what you did, where you found resources (books, videos, web pages, friends) to help you solve this. Remember to put the tag WSQ06 on your post so our blog hub picks that up.

You should include your code either inline in the blog post (best option) and/or a link to your actual code on Dropbox/Google Drive/GitHub.

You may want to check how to get started on GitHub now, here is a good article to start with: http://readwrite.com/2013/09/30/understanding-github-a-journey-for-beginners-part-1

And of course, leave any questions here as well as asking those questions on Twitter with the hashtag #TC1014 so we all see your question posted there.

CC BY 4.0 WSQ06 – Pick a Number by Ken Bauer is licensed under a Creative Commons Attribution 4.0 International License.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.