|
-
February 16th, 2009, 08:09 AM
#19
Re: Newbie'z first real program. Could use some CONSTRUCTIVE critizism to learn...
how's this....
and can someone tell me why cin.get(); won't work where I have the two scanf("%"); to pause it at the end...
thanks
Code:
#include <iostream>
#include <windows.h>
#define maxrand 40
#define maxrand2 50
using namespace std;
int iq = 0;
int iq2 = 0;
int calc = 0;
int y = 1;
int counter = 0;
int main()
{
cout << " Welcome to the : Guess Mr. Hell's IQ Game !!\n\n";
cout << " To Win You Will Have to follow these simple rules:\n\n";
cout << " * guess Mr. Hell's IQ in less than 8 tries,\n";
cout << " * Complete the questions asked after you get it,\n";
cout << " * You can't say no to ANY questions.\n";
cout << "\n Once You guess Mr. Hell's IQ,\n";
cout << " you will have to PROVE you're smarter than Mr. Hell\n";
cout << "\n\n What's Your First Guess ?\n\n";
srand( (unsigned)time( NULL ) );
int iqanswer = rand() % maxrand;
while(iq != maxrand, ++counter)
{
cin>>iq;
if(iq == iqanswer)
{
cout << "\n Right On ! You guessed it. He Really is THAT stupid !!\n\n";
break;
}
if(iq > iqanswer)cout <<"\n Too High\n\n Try Again: ";
if(iq < iqanswer)cout << "\n Too Low\n\n Try Again: ";
if(counter == 8)
{
cout << "\n\n You're Not Too Bright Yourself Now Are You ?";
cout << "\n Are You Sure You're Not Mr. Hell ?\n\n It Was: ";
cout<< iqanswer; cout << " Dumb-*** !\n\n";
break;
}
}
cout << " Now You Will Have To Guess George Bush's IQ\n\n";
cout << " Go Ahead and take a Wild Guess: ";
counter = 0;
int iqanswer2 = rand() % maxrand2;
while( iq2 != maxrand2, ++counter){
cin>>iq2;
if(iq2 == iqanswer2)
{
cout << "\n Nice Work ! You guessed it. He is also pretty Dumb huh ?\n\n\n\n";
break;
}
if(iq2 > iqanswer2)cout <<"\n Too High\n\nTry Again: ";
if(iq2 < iqanswer2)cout << "\n Too Low\n\nTry Again: ";
if(counter == 8)
{
cout << "\n\n You're Not Too Bright Yourself Now Are You ?\n";
cout << " Are You Sure You're Not Mr. Hell ?\n\nIt Was: ";
cout << iqanswer2; cout << " Dumb-*** !\n\n";
break;
}
}
cout << " Now You Will Need To Add The Two IQ's Together....\n\n";
cout << " If You Are As Dumb As Mr. Hell You May Need A Calculator...\n\n";
cout << " Would You like to use a Calculator ?\n\n";
cout << " press 1 for the calculator,\n";
cout << " press any other key for no if you think you don't need it.\n\n";
{
cin >> calc;
if(calc == y)
{
::ShellExecute(NULL,
"open",
"calc.exe",
"",
"",
SW_SHOWNORMAL);
}
else
{
cout << "\n\n\n\n\n\n\n\n\n\n Ha Ha You're as Dumb As Mr. Hell !!\n";
cout << " You Loose Sucker....\n\n";
cout << " You could NOT answer NO to ANY question REMEMBER ???";
}
if(calc == y )
{
int total;
int totalanswer = (iqanswer + iqanswer2);
cout << " Now add Mr. Hell's IQ to George Bush's IQ and type your answer here: ";
cin >> total;
if(total == totalanswer)
{
cout << "\n\n\n YOU WIN !!!\n\n Very Good !\n\n";
cout << " You Clearly are a step ahead of Mr. Hell, and your IQ is higher than Both\n";
cout << " Mr. Hell's and George Bush's IQ COMBINED !!";
}
else
{
cout << "\n\n * GAME OVER * Ha Ha !\n\n Your lack of adding skills suggests\n You are as Dumb as Mr. Hell !\n\n";
cout << " The Correct Answer was: ";
cout << totalanswer;
}
}
cout << "\n\n Thanks for Playing.\n\n You Are Now Worthy Of A Special Treat From\n\n";
cout << " The Worlds Greatest New Alien Rock Band...\n\n\n T H E P E R I S H !! \n\n\n\n";
cout << " press any key, then ENTER to continue... \n\n\n\n\n";
scanf("%"); // if I use cin.get(); here instead it does NOT pause and wait for a key press. WHY ??????
{
::ShellExecute(NULL,
"open",
"http://www.youtube.com/watch?v=TwazkWbE4Pk&feature=channel_page",
"",
"",
SW_SHOWNORMAL);
scanf("%");// if I use cin.get(); here instead it does NOT pause and wait for a key press. WHY ??????
}
}
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|