KeeganT

Programming Quiz

Jan 11th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.29 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int choice;
  6. int wrong=0, right=0, lives=0;
  7. int answer;
  8. string questions[20];
  9. int questionAnswers[20];
  10.  
  11. int livesChoice()
  12. {
  13.   do{
  14.     cout<<"You have chosen Lives mode"<<endl;
  15.     cout<<"Please choose your difficulty"<<endl;
  16.     cout<<"1) Easy (Lives)"<<endl;
  17.     cout<<"2) Medium (Lives)"<<endl;
  18.     cout<<"3) Hard (Lives)"<<endl;
  19.     cout<<"4) Return"<<endl;
  20.     cin>>choice;
  21.     if(choice==1)
  22.     {
  23.       lives==20;
  24.       modeL();
  25.     }
  26.     else if(choice==2)
  27.     {
  28.       lives==10;
  29.       modeL();
  30.     }
  31.     else if(choice==3)
  32.     {
  33.       lives==5;
  34.       modeL();
  35.     }
  36.     else if(choice==4)break;
  37.   }while(true);
  38. }
  39.  
  40. int accuracyChoice()
  41. {
  42.   do{
  43.     system("cls");
  44.     cout<<"You have one guess per qusetion,"<<endl;
  45.     cout<<"and when you reach the end of the quiz,"<<endl;
  46.     cout<<"your results will be revealed."<<endl;
  47.     cout<<"1) Continue"<<endl;
  48.     cout<<"2) Return"<<endl;
  49.     cin>>choice;
  50.     if(choice==1)
  51.     {
  52.       lives=(-1);
  53.       game(lives):
  54.     }
  55.     else if(choice==2)break;
  56.   }while(true);
  57. }
  58.  
  59. livesGame()
  60. {
  61.     for(int c=0;c<20;c++)
  62.     {
  63.         cout<<questiosn[c]<<endl;
  64.         cin>>answer;
  65.         if(answer==questionAnswers[c])cout<<"That's correct!"<<endl;
  66.         else lives--;
  67.         if(lives==0)
  68.         {
  69.             cout<<"You lost!"<<endl;
  70.             break;
  71.         }
  72.     }
  73. }
  74.  
  75. accuracyGame()
  76. {
  77.     for(int c=0;c<20;c++)
  78.     {
  79.         cout<<questions[c]<<endl;
  80.         cin>>answer;
  81.         if(answer==questionAnswers[c])
  82.         {
  83.             cout<<"That's correct!"<<endl;
  84.             right++;
  85.         }
  86.         else
  87.         {
  88.             cout<<"That's incorrect!"<<endl;
  89.             wrong++;
  90.         }
  91.     }
  92.     cout<<"You've completed the quiz!"<<endl;
  93.     cout<<"You had "<<right<<" many correct answers."<<endl;
  94.     cout<<"You had "<<wrong<<" many incorrect answers."<<endl;
  95. }
  96.  
  97. int quizMain()
  98. {
  99.   do{
  100.     cout<<"Programming Quiz!"<<endl;
  101.     cout<<"-----------------\n"<<endl;
  102.     system("cls");
  103.     cout<<"1) Lives"<<endl;
  104.     cout<<"2) Accuracy"<<endl;
  105.     cout<<"3) Return to Menu"<<endl;
  106.     cin>>choice;
  107.     if(choice==1)livesChoice();
  108.     else if(choice==2)accuracyChoice();
  109.     else if(choice==3)break;
  110.     wrong=0;
  111.     right=0;
  112.     lives=0;
  113.   }while(true);
  114. }
Advertisement
Add Comment
Please, Sign In to add comment