Thursday, July 30, 2009

Plzz help with my c++ program?

#include %26lt;conio.h%26gt;// needed for getch


#include %26lt;iostream.h%26gt;//needed for cout message


void startup();


void method();


int main()


{


startup();


method();


getch();


return 0;


}


void startup()


{


cout%26lt;%26lt;"safi khan"%26lt;%26lt;'\n';


cout%26lt;%26lt;"november 16, 2007"%26lt;%26lt;'\n';


cout%26lt;%26lt;"pg e"%26lt;%26lt;'\n';


cout%26lt;%26lt;""%26lt;%26lt;'\n';


}


void method()


{


int horl, p1;


float num;


cout%26lt;%26lt; "Think of a number between 1 through 100. \n";


cout%26lt;%26lt; "If done press 1.\n";


cin%26gt;%26gt;p1;


if (p1 = 1)


{


cout%26lt;%26lt; "Is it 50? Press 1) for too high 2) for too low 3) for I have it right 4) if you want to quit.\n";


cin%26gt;%26gt;horl;


}


if (horl == 1)


{


num = 50 / 2;


cout%26lt;%26lt;"Is it "%26lt;%26lt;num%26lt;%26lt;"? Press 1) for too high 2) for too low 3) for I have it right 4) if you want to quit.";


cin%26gt;%26gt;horl;


}


if (horl == 2)


{


num = 50 * 2;


cout%26lt;%26lt;"Is it "%26lt;%26lt;num%26lt;%26lt;"? Press 1) for too high 2) for too low 3) for I have it right 4) if you want to quit

Plzz help with my c++ program?
Yikes, what a mess.





1.) You will need a while loop that will continue until the user has pressed 3, or 4. You will need to prompt the user for their response through each iteration.





2.) You will need three integers: 'minimum' = 0, 'maximum' = 100, and 'guess' = (maximum - minimum) / 2





3.) In the while loop you will need to ask the user "Is this your value" and print out the 'guess'. If the user types


    3: print a "Game over", and then break.


    4: break.


    1: maximum = guess, guess = (max - min) / 2, continue


    2: minimum = guess, guess = (max - min) / 2, continue








That's it.


No comments:

Post a Comment