CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 29

Threaded View

  1. #1
    Join Date
    Feb 2009
    Posts
    80

    Talking Newbie'z first real program. Could use some CONSTRUCTIVE critizism to learn...

    Please keep in mind I only started programming 9 days ago. Before then all I knew was HTML and a touch of PHP ( not much ).

    I would love it if some of you pro's out there could take a look at this monster I've created over the last 2 days, and tell me if I could have, or should have done something different than what I've done.

    I Created a game called... " Mr. Hell's IQ "
    Mr. Hell is a guy on a message board out there in cyberspace who spends ALL DAY ripping on my band. We think it's hallarious. Some of the things he says are so increadibly stupid that we can't help but roll on the floor with laughter.
    This game is just for a laugh. You need to guess Mr. Hell's IQ , then go from there.
    it's fun.

    Please let me know if you think I could have done the code another way, or better way.

    Thanks everyone.

    Code:
    #include <iostream>
    #include <windows.h>
    using namespace std;
    int iq;
    int iq2;
    int calc;
    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 * guess Mr. Hell's IQ in less than 10 tries,\n * Complete the questions asked after you get it,\n * You can't say no to ANY questions.\n";
        cout << "\n Once You guess Mr. Hell's IQ,\n you will have to PROVE you're smarter than Mr. Hell\n";
        cout << "\n\n What's Your First Guess ?\n\n";
    
    
        int maxrand = 40;
        srand( (unsigned)time( NULL ) );
        int iqanswer = rand() &#37; maxrand;
    
        while(iq != maxrand, ++counter)
        {
    
        cin>>iq;
        if(iq == iqanswer)cout << "\n Right On !  You guessed it. He Really is THAT stupid !!\n\n";
        if(iq == iqanswer) 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 == 10)
        {
             cout << "\n\n You're Not Too Bright Yourself Now Are You ?\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 Go Ahead and take a Wild Guess: ";
    
        counter = 0;
    
        int maxrand2 = 50;
        srand( (unsigned)time( NULL ) ); 
        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";
        if(iq2 == iqanswer2) break;
        if(iq2 > iqanswer2)cout <<"\n Too High\n\nTry Again: ";
        if(iq2 < iqanswer2)cout << "\n Too Low\n\nTry Again: ";
        if(counter == 10)
        {
             cout << "\n\n You're Not Too Bright Yourself Now Are You ?\n 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 press  1  for the calculator,\n 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 Ha Ha You're as Dumb As Mr. Hell !!\n You Loose Sucker....\n\n 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 YOU WIN !!!\n\n Very Good !\n\n You Clearly are a step ahead of Mr. Hell, and your IQ is higher than Both\n Mr. Hell's and George Bush's IQ COMBINED !!\n\n\n\n";
    
        }
    
        else
        {
            cout <<  "\n\n Ha Ha !\n\n You lack of adding skills suggests\n You are as Dumb as Mr. Hell !\n\nThe Correct Answer was: "; cout << totalanswer;  cout << "\n\n\n\n";
        }
    
    
    
        }
    
        cout << "\n\n   GAME OVER\n\n  Press any key and Enter to close.";
        scanf("%");
        return 0;
       }
    }

    All critizism welcome !

    cheers.
    Last edited by Jeff++; February 15th, 2009 at 02:51 AM.

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
  •  





Click Here to Expand Forum to Full Width

Featured