help with guessing game program

This is a discussion on help with guessing game program within the C++ Programming forums, part of the General Programming Boards category; i have to make a program that has 1 tpoic and 10 questions relating to the topic. i am supposed ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    4

    Unhappy help with guessing game program

    i have to make a program that has 1 tpoic and 10 questions relating to the topic. i am supposed to use if statements and variables, but am having a real hard time. i dont understand them at all. can anyone help me. here is the code i have so far, but since i have no understanding of variables and if statements there are none here.

    Code:
    #include <iostream.h>
    #include <stdlib.h>
    
    
    //Jake Fletcher
    //2-2-06
    //6th Hour
    
    
    int main()
    {
    
    
    
          cout << "Welcome To Jake's Guessing Game! \n" ;
          cout << "The Topic Is: Rock n Roll \n" ;
          
          cout << "\n";
          
          cout << "1) What Band Sings: Living After Midnight? \n" ;
          cout << "   A) Judas Priest " << "C) AC/DC \n" ;
          cout << "   B) Cream        " << "D) Guns n Roses \n" ;
          //A) Judas Priest
          
          cout << "\n";
          
          cout << "2) Which Of The Following Isn't 1 Of The 4 Main Instruments In A Rock Band? \n" ;
          cout << "   A) Rythm Guitar " << "B) Banjo \n" ;
          cout << "   C) Drums        " << "D) Bass \n" ;
          //B) Banjo
          
          cout << "\n";
          
          cout << "3) What Is The Name Of Greatest Rock Band In The World? \n" ;
          cout << "   A) KISS           " << "C) Nazareth \n" ;
          cout << "   B) Rolling Stones " << "D) AC/DC \n" ;
          //B) Rolling Stones
          
          cout << "\n";
          
          cout << "4) What Band Sings: Hair Of A Dog? \n" ;
          cout << "   A) Metallica " << "C) Bachman Turner Overdrive \n" ;
          cout << "   B) The Who   " << "D) Nazareth \n" ;
          //D) Nazareth
          
          cout << "\n";
          
          cout << "5) Who Played Bass For The Beatles? \n" ;
          cout << "   A) Ringo Starr    " << "B) John Lennon \n" ;
          cout << "   C) Paul McCartney " << "D) George Harrison \n" ;
          //C) Paul McCartney
          
          cout << "\n";
          
          cout << "6) Who Is The Worlds Greatest Guitar Player? \n" ;
          cout << "   A) Jimi Hendrix   " << "C) Angus Young \n" ;
          cout << "   B) Eric Clapton " << "D) Jimmy Page \n" ;
          //C) Angus Young
          
          cout << "\n";
          
          cout << "7) Who Is The Worlds Greatest Bass Player? \n" ;
          cout << "   A) John Paul Jones " << "C) Cliff Williams \n" ;
          cout << "   B) Cliff Burton    " << "D) Flea \n" ;
          //A) John Paul Jones
    
          cout << "\n";
    
          cout << "8) Who Is The Worlds Greatest Drummer? \n" ;
          cout << "   A) Neal Peart  " << "B) Lars Ulrich \n" ;
          cout << "   C) Chris Slade " << "D) John Bonham \n" ;
          //A) Neal Peart
          
          cout << "\n";
          
          cout << "9) Who Is The Worlds Greatest Rock Singer? \n" ;
          cout << "   A) Freddie Mercury   " << "C) Brian Johnson \n" ;
          cout << "   B) Robert Plant      " << "D) Klaus Meine \n" ;
          //B) Robert Plant
          
          cout << "\n";
          
          cout << "10) Which Of The Following Is The Greatest Rock Song OF All Time? \n" ;
          cout << "    A) Stairway To Heaven " << "C) Sympathy For The Devil \n" ;
          cout << "    B) Layla              " << "D) Satisfaction \n" ;
          //D) Satisfaction
      
          system("PAUSE");
          return 0;
    }
    any and all help is highly appreciated.

  2. #2
    Registered User
    Join Date
    Jan 2006
    Posts
    20
    Well an if/else statement looks like this:

    Code:
    if( expression )
    {
        // do this
    } else {
       // do this
    }
    If you don't understand what a variable is, i suggest you read a good book/tutorial about C++.

  3. #3
    I Write C++ Apps, Sue Me.
    Join Date
    Feb 2006
    Location
    In My Computer
    Posts
    44
    Sorry if its not, but this sounds school related, you should look over what you learned. Its pretty simple though, you just have to declare a variable for each question
    Code:
     
    char q1;
    char q2;
    and then use cin to replace the variable with the users choice.
    Code:
    #include <iostream.h>
    #include <stdlib.h>
    
    
    //Jake Fletcher
    //2-2-06
    //6th Hour
    
    
    int main()
    {
    char q1;  //Declares the character variable "q1".
    
    
          cout << "Welcome To Jake's Guessing Game! \n" ;
          cout << "The Topic Is: Rock n Roll \n" ;
          
          cout << "\n";
          
          cout << "1) What Band Sings: Living After Midnight? \n" ;
          cout << "   A) Judas Priest " << "C) AC/DC \n" ;
          cout << "   B) Cream        " << "D) Guns n Roses \n" ;
          //A) Judas Priest
         cout <<"Answer: ";
         cin>>q1;  //Replaces The Variable "q1" with the players choice.
         cin.ignore();  //Ignores the Press of the enter key.
    Basically you just make a char for each question, use cin to define replace the variable with the users choice, and use cin.ignore() to ignore the enter key.

    As for if statements:
    Code:
    if (q1=='a') {
    cout <<"Question 1: Correct!";
    }
    else {
    cout<<"Question 1: Wrong!";
    }
    You can do that for each question Variable replacing the 'a' with the answer to that particular question. Remember, you have to have ' ' around your answer because you are using characters not numbers. Also, == means check for equality while just = means set equal to.
    Enjoy,
    Kyle
    Last edited by comwiz; 02-05-2006 at 02:10 PM.

  4. #4
    Registered User
    Join Date
    Feb 2006
    Posts
    4
    yeah this is for school, but i have missed a few days, dont have my book, and have no clue as what to do. we just started this on thursday. but this isnt for a grade, its so we can learn how things work. can someone tell me how i can add a counter, so a question i ansewrd right it gives them one point?

  5. #5
    I Write C++ Apps, Sue Me.
    Join Date
    Feb 2006
    Location
    In My Computer
    Posts
    44
    Code:
    int score = 0;  //Sets the Variable "score" to zero.
    Code:
    if (q1=='a') {
    cout <<"Question 1: Correct!";
    score = score + #  //Replace # w/ how many points to give for the question.
    }
    else {
    cout<<"Question 1: Wrong!";
    }
    if (q2=='b') {
    cout<<"Question 2: Correct!";
    score = score + #  
    }
    else {
    cout<<"Question 2: Wrong!";
    }
    At the end of the Program:
    Code:
    cout<<"Your Score: "<< score <<"\n";  // Prints the value of variable "score".
    Last edited by comwiz; 02-05-2006 at 02:47 PM.

  6. #6
    Registered User
    Join Date
    Feb 2006
    Posts
    4
    thx for the help. one tiny problem now though, it wont run, to many errors.

    Code:
    #include <iostream.h>
    #include <stdlib.h>
    
    
    //Jake Fletcher
    //2-2-06
    //6th Hour
    
    
    int main()
    {
    
          char q1;  //Declares the character variable "q1".
          char q2;  //Declares the character variable "q2".
          char q3;  //Declares the character variable "q3".
          char q4;  //Declares the character variable "q4".
          char q5;  //Declares the character variable "q5".
          char q6;  //Declares the character variable "q6".
          char q7;  //Declares the character variable "q7".
          char q8;  //Declares the character variable "q8".
          char q9;  //Declares the character variable "q9".
          char q10;  //Declares the character variable "q10".
          
          int score = 0;  //Sets the Variable "score" to zero.
    
          cout << "Welcome To Jake's Guessing Game! \n" ;
          cout << "The Topic Is: Rock n Roll \n" ;
          
          cout << "\n";
          
          cout << "1) What Band Sings: Living After Midnight? \n" ;
          cout << "   A) Judas Priest " << "C) AC/DC \n" ;
          cout << "   B) Cream        " << "D) Guns n Roses \n" ;
          //A) Judas Priest
          
          cout <<"Answer: ";
          cin>>q1;  //Replaces The Variable "q1" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q1='a') {
          cout <<"Question 1: Correct!";
          score + #  //Replace # w/ how many points to give for the question.
          }
          else {
          cout <<"Question 1: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "2) Which Of The Following Isn't 1 Of The 4 Main Instruments In A Rock Band? \n" ;
          cout << "   A) Rythm Guitar " << "B) Banjo \n" ;
          cout << "   C) Drums        " << "D) Bass \n" ;
          //B) Banjo
          
          cout <<"Answer: ";
          cin>>q2;  //Replaces The Variable "q2" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q2='b') {
          cout <<"Question 2: Correct!";
          score + #  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 2: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "3) What Is The Name Of Greatest Rock Band In The World? \n" ;
          cout << "   A) KISS           " << "C) Nazareth \n" ;
          cout << "   B) Rolling Stones " << "D) AC/DC \n" ;
          //B) Rolling Stones
     
          cout <<"Answer: ";
          cin>>q3;  //Replaces The Variable "q3" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q3='b') {
          cout <<"Question 3: Correct!";
          score + #  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 3: Wrong!";
          }
       
          cout << "\n";
          cout << endl;
          
          cout << "4) What Band Sings: Hair Of A Dog? \n" ;
          cout << "   A) Metallica " << "C) Bachman Turner Overdrive \n" ;
          cout << "   B) The Who   " << "D) Nazareth \n" ;
          //D) Nazareth
         
          cout <<"Answer: ";
          cin>>q4;  //Replaces The Variable "q4" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q4='d') {
          cout <<"Question 4: Correct!";
          score + #  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 4: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "5) Who Played Bass For The Beatles? \n" ;
          cout << "   A) Ringo Starr    " << "B) John Lennon \n" ;
          cout << "   C) Paul McCartney " << "D) George Harrison \n" ;
          //C) Paul McCartney
          
          cout <<"Answer: ";
          cin>>q5;  //Replaces The Variable "q5" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q5='c') {
          cout <<"Question 5: Correct!";
          score + #  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 5: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "6) Who Is The Worlds Greatest Guitar Player? \n" ;
          cout << "   A) Jimi Hendrix   " << "C) Angus Young \n" ;
          cout << "   B) Eric Clapton " << "D) Jimmy Page \n" ;
          //C) Angus Young
           
          cout <<"Answer: ";
          cin>>q6;  //Replaces The Variable "q6" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q6='c') {
          cout <<"Question 6: Correct!";
          score + #  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 6: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "7) Who Is The Worlds Greatest Bass Player? \n" ;
          cout << "   A) John Paul Jones " << "C) Cliff Williams \n" ;
          cout << "   B) Cliff Burton    " << "D) Flea \n" ;
          //A) John Paul Jones
          
          cout <<"Answer: ";
          cin>>q7;  //Replaces The Variable "q7" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q7='a') {
          cout <<"Question 7: Correct!";
          score + #  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 7: Wrong!";
          }
    
          cout << "\n";
          cout << endl;
    
          cout << "8) Who Is The Worlds Greatest Drummer? \n" ;
          cout << "   A) Neal Peart  " << "B) Lars Ulrich \n" ;
          cout << "   C) Chris Slade " << "D) John Bonham \n" ;
          //A) Neal Peart
         
          cout <<"Answer: ";
          cin>>q8;  //Replaces The Variable "q81" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q8='a') {
          cout <<"Question 8: Correct!";
          score + #  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 8: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "9) Who Is The Worlds Greatest Rock Singer? \n" ;
          cout << "   A) Freddie Mercury   " << "C) Brian Johnson \n" ;
          cout << "   B) Robert Plant      " << "D) Klaus Meine \n" ;
          //B) Robert Plant
           
          cout <<"Answer: ";
          cin>>q9;  //Replaces The Variable "q9" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q9='b') {
          cout <<"Question 9: Correct!";
          score + #  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 9: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "10) Which Of The Following Is The Greatest Rock Song OF All Time? \n" ;
          cout << "    A) Stairway To Heaven " << "C) Sympathy For The Devil \n" ;
          cout << "    B) Layla              " << "D) Satisfaction \n" ;
          //D) Satisfaction
         
          cout <<"Answer: ";
          cin>>q10;  //Replaces The Variable "q10" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q10='d') {
          cout <<"Question 10: Correct!";
          score + #  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 10: Wrong!";
          }
          
          cout<<"Your Score: "<< score <<"\n";  // Prints the value of variable "score".
      
          system("PAUSE");
          return 0;
    }
    and again this program is for notes, so we know and understand how if statements and variables/characters work.

  7. #7
    I Write C++ Apps, Sue Me.
    Join Date
    Feb 2006
    Location
    In My Computer
    Posts
    44
    You have to make it look like this:
    Code:
    if (q1='a') {
          cout <<"Question 1: Correct!";
          score = score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout <<"Question 1: Wrong!";
          }
    You didnt replace the #'s with an actual number of points to reward the player.
    -Kyle

  8. #8
    Registered User
    Join Date
    Mar 2002
    Posts
    203
    Your if's are using equals instead of equal to. Equal to is two equals (==). Try to remember that because it usually won't cause any compiler errors.
    Your errors are probably all from score + #. It needs to be score = score + #; or score += #;
    You really don't need 10 different char variables for the answer unless you want to keep track of what they picked for each question.

  9. #9
    I Write C++ Apps, Sue Me.
    Join Date
    Feb 2006
    Location
    In My Computer
    Posts
    44
    no there not, its from the # symbols, you have to replace them with an actual integer for it to work, I was just showing an example, the commenting even said that.
    -Kyle

  10. #10
    I Write C++ Apps, Sue Me.
    Join Date
    Feb 2006
    Location
    In My Computer
    Posts
    44
    Alright, I fixxed your mistakes and got it to compile w/o error:
    Code:
    #include <iostream>
    #include <stdlib.h>
    using namespace std;
    
    //Jake Fletcher
    //2-2-06
    //6th Hour
    
    
    int main()
    {
    
          char q1;  //Declares the character variable "q1".
          char q2;  //Declares the character variable "q2".
          char q3;  //Declares the character variable "q3".
          char q4;  //Declares the character variable "q4".
          char q5;  //Declares the character variable "q5".
          char q6;  //Declares the character variable "q6".
          char q7;  //Declares the character variable "q7".
          char q8;  //Declares the character variable "q8".
          char q9;  //Declares the character variable "q9".
          char q10;  //Declares the character variable "q10".
          
          int score = 0;  //Sets the Variable "score" to zero.
    
          cout << "Welcome To Jake's Guessing Game! \n" ;
          cout << "The Topic Is: Rock n Roll \n" ;
          
          cout << "\n";
          
          cout << "1) What Band Sings: Living After Midnight? \n" ;
          cout << "   A) Judas Priest " << "C) AC/DC \n" ;
          cout << "   B) Cream        " << "D) Guns n Roses \n" ;
          //A) Judas Priest
          
          cout <<"Answer: ";
          cin>>q1;  //Replaces The Variable "q1" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q1='a') {
          cout <<"Question 1: Correct!";
          score = score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout <<"Question 1: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "2) Which Of The Following Isn't 1 Of The 4 Main Instruments In A Rock Band? \n" ;
          cout << "   A) Rythm Guitar " << "B) Banjo \n" ;
          cout << "   C) Drums        " << "D) Bass \n" ;
          //B) Banjo
          
          cout <<"Answer: ";
          cin>>q2;  //Replaces The Variable "q2" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q2='b') {
          cout <<"Question 2: Correct!";
          score = score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 2: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "3) What Is The Name Of Greatest Rock Band In The World? \n" ;
          cout << "   A) KISS           " << "C) Nazareth \n" ;
          cout << "   B) Rolling Stones " << "D) AC/DC \n" ;
          //B) Rolling Stones
     
          cout <<"Answer: ";
          cin>>q3;  //Replaces The Variable "q3" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q3='b') {
          cout <<"Question 3: Correct!";
          score = score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 3: Wrong!";
          }
       
          cout << "\n";
          cout << endl;
          
          cout << "4) What Band Sings: Hair Of A Dog? \n" ;
          cout << "   A) Metallica " << "C) Bachman Turner Overdrive \n" ;
          cout << "   B) The Who   " << "D) Nazareth \n" ;
          //D) Nazareth
         
          cout <<"Answer: ";
          cin>>q4;  //Replaces The Variable "q4" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q4='d') {
          cout <<"Question 4: Correct!";
          score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 4: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "5) Who Played Bass For The Beatles? \n" ;
          cout << "   A) Ringo Starr    " << "B) John Lennon \n" ;
          cout << "   C) Paul McCartney " << "D) George Harrison \n" ;
          //C) Paul McCartney
          
          cout <<"Answer: ";
          cin>>q5;  //Replaces The Variable "q5" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q5='c') {
          cout <<"Question 5: Correct!";
          score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 5: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "6) Who Is The Worlds Greatest Guitar Player? \n" ;
          cout << "   A) Jimi Hendrix   " << "C) Angus Young \n" ;
          cout << "   B) Eric Clapton " << "D) Jimmy Page \n" ;
          //C) Angus Young
           
          cout <<"Answer: ";
          cin>>q6;  //Replaces The Variable "q6" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q6='c') {
          cout <<"Question 6: Correct!";
          score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 6: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "7) Who Is The Worlds Greatest Bass Player? \n" ;
          cout << "   A) John Paul Jones " << "C) Cliff Williams \n" ;
          cout << "   B) Cliff Burton    " << "D) Flea \n" ;
          //A) John Paul Jones
          
          cout <<"Answer: ";
          cin>>q7;  //Replaces The Variable "q7" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q7='a') {
          cout <<"Question 7: Correct!";
          score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 7: Wrong!";
          }
    
          cout << "\n";
          cout << endl;
    
          cout << "8) Who Is The Worlds Greatest Drummer? \n" ;
          cout << "   A) Neal Peart  " << "B) Lars Ulrich \n" ;
          cout << "   C) Chris Slade " << "D) John Bonham \n" ;
          //A) Neal Peart
         
          cout <<"Answer: ";
          cin>>q8;  //Replaces The Variable "q81" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q8='a') {
          cout <<"Question 8: Correct!";
          score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 8: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "9) Who Is The Worlds Greatest Rock Singer? \n" ;
          cout << "   A) Freddie Mercury   " << "C) Brian Johnson \n" ;
          cout << "   B) Robert Plant      " << "D) Klaus Meine \n" ;
          //B) Robert Plant
           
          cout <<"Answer: ";
          cin>>q9;  //Replaces The Variable "q9" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q9='b') {
          cout <<"Question 9: Correct!";
          score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 9: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "10) Which Of The Following Is The Greatest Rock Song OF All Time? \n" ;
          cout << "    A) Stairway To Heaven " << "C) Sympathy For The Devil \n" ;
          cout << "    B) Layla              " << "D) Satisfaction \n" ;
          //D) Satisfaction
         
          cout <<"Answer: ";
          cin>>q10;  //Replaces The Variable "q10" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q10='d') {
          cout <<"Question 10: Correct!";
          score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 10: Wrong!";
          }
          
          cout<<"Your Score: "<< score <<"\n";  // Prints the value of variable "score".
      
          system("PAUSE");
          return 0;
    }
    Also, If you want to ensure there wont be any error, put the following under each cin.ignore();
    Code:
    q#=tolower(q#); //REPLACE # with the number of the variable.
    
    Ex.
    
    q2=tolower(q2);
    That will make all the characters lower case and ensure that there are no errors with the if statements, if you didnt do that and someone entered an Uppercase Letter instead of a lowercase letter it would say you got it right even if you didnt.
    Enjoy
    -Kyle
    Last edited by comwiz; 02-05-2006 at 03:12 PM.

  11. #11
    Registered User
    Join Date
    Feb 2006
    Posts
    4
    thx again

  12. #12
    I Write C++ Apps, Sue Me.
    Join Date
    Feb 2006
    Location
    In My Computer
    Posts
    44
    Your welcome
    -Kyle

  13. #13
    Registered User
    Join Date
    Jan 2005
    Posts
    7,344
    >> Alright, I fixxed your mistakes

    There are still mistakes in that code. Syneris pointed out a major problem already that still needs to be fixed.

  14. #14
    I Write C++ Apps, Sue Me.
    Join Date
    Feb 2006
    Location
    In My Computer
    Posts
    44
    Code:
    #include <iostream>
    #include <stdlib.h>
    using namespace std;
    
    //Jake Fletcher
    //2-2-06
    //6th Hour
    
    
    int main()
    {
    
          char q1;  //Declares the character variable "q1".
          char q2;  //Declares the character variable "q2".
          char q3;  //Declares the character variable "q3".
          char q4;  //Declares the character variable "q4".
          char q5;  //Declares the character variable "q5".
          char q6;  //Declares the character variable "q6".
          char q7;  //Declares the character variable "q7".
          char q8;  //Declares the character variable "q8".
          char q9;  //Declares the character variable "q9".
          char q10;  //Declares the character variable "q10".
          
          int score = 0;  //Sets the Variable "score" to zero.
    
          cout << "Welcome To Jake's Guessing Game! \n" ;
          cout << "The Topic Is: Rock n Roll \n" ;
          
          cout << "\n";
          
          cout << "1) What Band Sings: Living After Midnight? \n" ;
          cout << "   A) Judas Priest " << "C) AC/DC \n" ;
          cout << "   B) Cream        " << "D) Guns n Roses \n" ;
          //A) Judas Priest
          
          cout <<"Answer: ";
          cin>>q1;  //Replaces The Variable "q1" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q1=='a') {
          cout <<"Question 1: Correct!";
          score = score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout <<"Question 1: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "2) Which Of The Following Isn't 1 Of The 4 Main Instruments In A Rock Band? \n" ;
          cout << "   A) Rythm Guitar " << "B) Banjo \n" ;
          cout << "   C) Drums        " << "D) Bass \n" ;
          //B) Banjo
          
          cout <<"Answer: ";
          cin>>q2;  //Replaces The Variable "q2" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q2=='b') {
          cout <<"Question 2: Correct!";
          score = score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 2: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "3) What Is The Name Of Greatest Rock Band In The World? \n" ;
          cout << "   A) KISS           " << "C) Nazareth \n" ;
          cout << "   B) Rolling Stones " << "D) AC/DC \n" ;
          //B) Rolling Stones
     
          cout <<"Answer: ";
          cin>>q3;  //Replaces The Variable "q3" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q3=='b') {
          cout <<"Question 3: Correct!";
          score = score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 3: Wrong!";
          }
       
          cout << "\n";
          cout << endl;
          
          cout << "4) What Band Sings: Hair Of A Dog? \n" ;
          cout << "   A) Metallica " << "C) Bachman Turner Overdrive \n" ;
          cout << "   B) The Who   " << "D) Nazareth \n" ;
          //D) Nazareth
         
          cout <<"Answer: ";
          cin>>q4;  //Replaces The Variable "q4" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q4=='d') {
          cout <<"Question 4: Correct!";
          score = score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 4: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "5) Who Played Bass For The Beatles? \n" ;
          cout << "   A) Ringo Starr    " << "B) John Lennon \n" ;
          cout << "   C) Paul McCartney " << "D) George Harrison \n" ;
          //C) Paul McCartney
          
          cout <<"Answer: ";
          cin>>q5;  //Replaces The Variable "q5" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q5=='c') {
          cout <<"Question 5: Correct!";
          score = score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 5: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "6) Who Is The Worlds Greatest Guitar Player? \n" ;
          cout << "   A) Jimi Hendrix   " << "C) Angus Young \n" ;
          cout << "   B) Eric Clapton " << "D) Jimmy Page \n" ;
          //C) Angus Young
           
          cout <<"Answer: ";
          cin>>q6;  //Replaces The Variable "q6" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q6=='c') {
          cout <<"Question 6: Correct!";
          score = score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 6: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "7) Who Is The Worlds Greatest Bass Player? \n" ;
          cout << "   A) John Paul Jones " << "C) Cliff Williams \n" ;
          cout << "   B) Cliff Burton    " << "D) Flea \n" ;
          //A) John Paul Jones
          
          cout <<"Answer: ";
          cin>>q7;  //Replaces The Variable "q7" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q7=='a') {
          cout <<"Question 7: Correct!";
          score = score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 7: Wrong!";
          }
    
          cout << "\n";
          cout << endl;
    
          cout << "8) Who Is The Worlds Greatest Drummer? \n" ;
          cout << "   A) Neal Peart  " << "B) Lars Ulrich \n" ;
          cout << "   C) Chris Slade " << "D) John Bonham \n" ;
          //A) Neal Peart
         
          cout <<"Answer: ";
          cin>>q8;  //Replaces The Variable "q81" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q8=='a') {
          cout <<"Question 8: Correct!";
          score = score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 8: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "9) Who Is The Worlds Greatest Rock Singer? \n" ;
          cout << "   A) Freddie Mercury   " << "C) Brian Johnson \n" ;
          cout << "   B) Robert Plant      " << "D) Klaus Meine \n" ;
          //B) Robert Plant
           
          cout <<"Answer: ";
          cin>>q9;  //Replaces The Variable "q9" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q9=='b') {
          cout <<"Question 9: Correct!";
          score = score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 9: Wrong!";
          }
          
          cout << "\n";
          cout << endl;
          
          cout << "10) Which Of The Following Is The Greatest Rock Song OF All Time? \n" ;
          cout << "    A) Stairway To Heaven " << "C) Sympathy For The Devil \n" ;
          cout << "    B) Layla              " << "D) Satisfaction \n" ;
          //D) Satisfaction
         
          cout <<"Answer: ";
          cin>>q10;  //Replaces The Variable "q10" with the players choice.
          cin.ignore();  //Ignores the Press of the enter key.
          
          if (q10=='d') {
          cout <<"Question 10: Correct!";
          score = score + 1;  //Replace # w/ how many points to give for the question.
          }
          else {
          cout<<"Question 10: Wrong!";
          }
          
          cout<<"Your Score: "<< score <<"\n";  // Prints the value of variable "score".
      
          system("PAUSE");
          return 0;
    }
    Final And Fixed.
    Last edited by comwiz; 02-07-2006 at 08:21 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 01:48 AM
  2. Random guessing game
    By Nalif in forum C Programming
    Replies: 16
    Last Post: 10-26-2006, 04:05 AM
  3. PC Game project requires c++ programmers
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 02-22-2006, 12:23 AM
  4. My number guessing game
    By The Gweech in forum C++ Programming
    Replies: 7
    Last Post: 06-22-2002, 10:03 AM
  5. Help with guessing game im making
    By Unregistered in forum C++ Programming
    Replies: 14
    Last Post: 06-06-2002, 10:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21