If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Age guessing game

Write a program that predicts users’ age (0-128 years old) with at most 7 questions. The game starts with asking the user whether he/she is younger or older than G (an initial guess). The user responds with 'O’ for older', ‘Y for 'younger' and ‘X’ for ‘you got it!’
Use a while loop to ask user whether his/her age is ‘>’, ’<’ or ‘=’ the guess. Update the guess using the binary search method. Note that you are not allowed to use “break”. cant figure out where i'm going wrong. tried to change a few things when it wouldn't compile till i got lost in my own code.

Re: Age guessing game

The character A could be entered in as Y caps or y or O or o or X or x
where O represents being older than the originak guess, y is younger and x means the programmes guess is correct.

There seems to be a trend lately where people just try to guess at the syntax. What you posted isn't even close to correct, and honestly, pointing out the mistakes seems kind of pointless. Take your time with a good book and learn the basics. You won't get anywhere throwing stuff at the wall to see what sticks.

Re: Age guessing game

"There seems to be a trend lately where people just try to guess at the syntax"

It's not just on codeguru forums either. Other forums are also having these types of questions posted.

There's also seems to be a trend where people don't, or don't know how, to debug programs properly that compile but don't perform as expected.

I'm going to be kind to the students and say the problem is that some tutors are setting some c++ programming problems without giving the students enough understanding in program design, testing/debugging and language syntax for some students to competently complete the designated assignment. Learning to program in a language like c++ from scratch can be terribly difficult at first until it all starts to fall into place. That's where having a good introductory book on c++ programming really helps. It takes practice and experience to 'think like a progammer'.

Re: Age guessing game

There seems to be a trend lately where people just try to guess at the syntax.

And to add, there is no computer language that, as far as I know, can be learned from guesswork, regardless of how simple or easy the language may seem to be.

Even a professional programmer using a tough language like C++ would need a tutorial, book, examples, on getting a BASIC program to work properly, if that person never saw BASIC before. I wish the tutors would emphasize that point about guessing -- learning programming is not a guessing game, but as you stated, it seems to be a trend now.

Re: Age guessing game

Originally Posted by Paul McKenzie

And to add, there is no computer language that, as far as I know, can be learned from guesswork, regardless of how simple or easy the language may seem to be.

Even a professional programmer using a tough language like C++ would need a tutorial, book, examples, on getting a BASIC program to work properly, if that person never saw BASIC before. I wish the tutors would emphasize that point about guessing -- learning programming is not a guessing game, but as you stated, it seems to be a trend now.

Regards,

Paul McKenzie

I was a COBOL programmer for years before switching to C++. Even then it took about three months before I was moderately productive at C++ and at least a year before I was comfortable with it.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.