Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. #include <string>
  5. #include "det_answers.h"
  6.  
  7. using namespace std;
  8.  
  9. string choose_question(int x);
  10. int det_answers(int x);
  11. string get_answer(int x, int y);
  12.  
  13. int main() //Main function that sets the rules of the game//
  14. {
  15. int correct_answers=0;
  16. int money=10;
  17. int tries=3;
  18. int questions=0;
  19. int *ptr;
  20. string question_components[10][2];
  21. string input_answer;
  22. int x=0;
  23. srand(time(0));
  24. x=((rand()%9));
  25. ptr=&x;
  26. cout<<"***************WELCOME TO WHO WANTS TO BE A MILLIONARIE!!!*****************\n\n";
  27. for(int r=0;r<10;r++)
  28. {
  29. for(int t=0;t<2;t++)
  30. {
  31. question_components[r][t]='0';
  32. }
  33. }
  34. while(questions<8 && tries>0)
  35. {
  36. int y=0;
  37. x++;
  38. if (x>9)
  39. {
  40. x=0;
  41. }
  42. question_components[*ptr][0]=choose_question(x);
  43.  
  44. y=det_answers(x);
  45.  
  46. cout<<question_components[*ptr][0]<<endl;
  47.  
  48. question_components[x][1]=get_answer(x,y);
  49.  
  50. cout<<"Choose an answer: ";
  51. cin>>input_answer;
  52.  
  53.  
  54. if( question_components[*ptr][1]==input_answer)
  55. {
  56. cout<<"Correct"<<endl;
  57. questions++;
  58. money=money*10;
  59. cout<<"You have gotten $"<<money<<" Congrats!"<<endl<<endl;
  60. }
  61. else
  62. {
  63. cout<<"Incorrect"<<endl;
  64. tries--;
  65. cout<<"You have "<<tries<<" lives remaining"<<endl<<endl;
  66. }
  67. }
  68. if(tries==0)
  69. {
  70. cout<<"YOU'VE LOST >_>";
  71. }
  72. else
  73. {
  74. cout<<"YOU'VE WON "<<money;
  75. }
  76. return 0;
  77. }
  78.  
  79. string choose_question(int x) //Function randomly chooses a question//
  80. {
  81. string question_num[10];
  82. string question;
  83.  
  84. question_num[0]="Modern football is said to have evolved from?\n";
  85.  
  86. question_num[1]="What is the Intelligence agency of UK?\n";
  87.  
  88. question_num[2]="Name the nuclear plant that closed for ever in Ukrain.\n";
  89.  
  90. question_num[3]="Which football club does Cristiano Ronaldo play for?\n";
  91.  
  92. question_num[4]="Which mosque is the biggest in the world?\n";
  93.  
  94. question_num[5]="What is the Japanese word for Goodbye?\n";
  95.  
  96. question_num[6]="There is only one continent on the earth that \ndoesn't have any deserts. Which is that continent?\n";
  97.  
  98. question_num[7]="What is the color of an emerald?\n";
  99.  
  100. question_num[8]="Where is the Changi International Airport located?\n";
  101.  
  102. question_num[9]="What am I going to get for this Project?\n";
  103.  
  104.  
  105. return question_num[x];
  106. }
  107. int det_answers(int x); //Calls external function to determine the answer/
  108. string get_answer(int x, int y) //Retrieves answers based on question generated//
  109. {
  110.  
  111. string multiple_choice[4];
  112. string answer;
  113. if(x==0)
  114. {
  115. multiple_choice[0]="a) England";
  116. multiple_choice[1]="b) India ";
  117. multiple_choice[2]="c) France";
  118. multiple_choice[3]="d) Canada";
  119. answer="a";
  120. }
  121. else if(x==1)
  122. {
  123. multiple_choice[0]="a) MI6 ";
  124. multiple_choice[1]="b) MI5";
  125. multiple_choice[2]="c) CIA";
  126. multiple_choice[3]="d) LOL";
  127. answer="b";
  128. }
  129. else if(x==2)
  130. {
  131. multiple_choice[0]="a) Kuala Lumpur";
  132. multiple_choice[1]="b) Nicaragua";
  133. multiple_choice[2]="c) Chernobyl";
  134. multiple_choice[3]="d) Texas";
  135. answer="c";
  136. }
  137. else if(x==3)
  138. {
  139. multiple_choice[0]="a) Juventus";
  140. multiple_choice[1]="b) Real Madrid";
  141. multiple_choice[2]="c) Manchester United";
  142. multiple_choice[3]="d) Barcelona";
  143. answer="a";
  144. }
  145. else if(x==4)
  146. {
  147. multiple_choice[0]="a) Federal Territory Mosque";
  148. multiple_choice[1]="b) Al-Aqsa Mosque";
  149. multiple_choice[2]="c) The Prophet's Mosque";
  150. multiple_choice[3]="d) Al-Haram Mosque";
  151. answer="d";
  152.  
  153. }
  154. else if(x==5)
  155. {
  156. multiple_choice[0]="a) Au revoir";
  157. multiple_choice[1]="b) Goodbye";
  158. multiple_choice[2]="c) Sayonara";
  159. multiple_choice[3]="d) Arrivederci";
  160. answer="c";
  161.  
  162. }
  163. else if(x==6)
  164. {
  165. multiple_choice[0]="a) Europe";
  166. multiple_choice[1]="b) North America";
  167. multiple_choice[2]="c) Africa";
  168. multiple_choice[3]="d) Asia";
  169. answer="a";
  170.  
  171. }
  172. else if(x==7)
  173. {
  174. multiple_choice[0]="a) Yellow";
  175. multiple_choice[1]="b) Red";
  176. multiple_choice[2]="c) Blue";
  177. multiple_choice[3]="d) Green";
  178. answer="d";
  179. }
  180. else if(x==8)
  181. {
  182. multiple_choice[0]="a) Vietnam";
  183. multiple_choice[1]="b) Thailand";
  184. multiple_choice[2]="c) Taiwan";
  185. multiple_choice[3]="d) Singapore";
  186. answer="d";
  187. }
  188. else if(x==9)
  189. {
  190. multiple_choice[0]="a) 100%";
  191. multiple_choice[1]="b) 100%";
  192. multiple_choice[2]="c) 100%";
  193. multiple_choice[3]="d) 100%";
  194. answer="a";
  195. }
  196. for(int i=0;i<4;i++)
  197. {
  198. cout<<multiple_choice[i]<<endl;
  199. }
  200.  
  201. return answer;
  202.  
  203. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement