Coding Challenge 6

For our 6th coding challenge, we are going to be working with a while statement and a postfix increment operator.  With these components, we are going to make a brute force age guessing program.  

First off, we will need two int variables one we will name guessAge and we will set it to 0.  We will name the other int userAge and the user will input their actual age.

Next, we will create a while statement that will print a guess every time it compares the two ints.  Also, be sure to put an increment operator inside of the while loop.  

Then, once it arrives at the correct age, it will exit the while loop and print out the user’s age.  Try to get your program to print the following (if the userAge value is 6):

If you find yourself stuck, feel free to scroll down to the bottom of the page to see what I got for my program.  Good luck and happy coding!

Great job and see you in the next chapter!

GitHub link.

Leave a Reply

%d bloggers like this: