Advertisement
jaredphoenix

Part 2 - testUser

Dec 15th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.26 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. string name;
  9.  
  10. cout << "Enter Your username: " << endl;
  11. getline (cin, name);
  12. string password;
  13.  
  14.  
  15.  
  16. cout << "Enter Your password: " << endl;
  17. getline (cin, password);
  18.  
  19. string start = "";
  20.  
  21. int a;
  22. int s;
  23.  
  24. cout << " You are now logged in. Type 'Go' to begin the quiz or 'Exit' to quit\n" << endl;
  25. cin >> start;
  26. cout << "\n" << endl;
  27.  
  28. if (start == "exit" || start == "Exit")
  29. {
  30. cout << "Thanks for taking the quiz! Press Enter to exit\n";
  31. cin.ignore();
  32. cin.get();
  33. return 0;
  34. }
  35.  
  36.  
  37.  
  38. if (start == "go" || start == "Go")
  39. {
  40. string q1 = "";
  41.  
  42. cout << "Question 1:\nWhat is the only function all C++ programs must contain?\n\n1 = 'sart()'\n"
  43. << "2 = 'program()'\n3 = 'main()'\n4 ="
  44. << " 'system()'\n" << endl;
  45. cin >> q1;
  46. cout << "\n" << endl;
  47.  
  48. if (q1 == "3")
  49. {
  50. a = 0;
  51. a = a + 1;
  52. }
  53.  
  54. if (q1 == "exit")
  55. {
  56. cout << "Thanks for taking the quiz! Press Enter to exit\n";
  57. cin.ignore();
  58. cin.get();
  59. return 0;
  60. }
  61. string q2 = "";
  62. cout << "Question 2:\nWhat punctuation is used to signal the beginning and end of code blocks?\n\n1 = '(and)'\n"
  63. << "2 = '-> and C. Begin and End)'\n3 = '{ }'\n4 ="
  64. << " '//\\'\n" << endl;
  65. cin >> q2;
  66. cout << "\n" << endl;
  67.  
  68. if (q2 == "3")
  69. {
  70. a = 0;
  71. a = a + 1;
  72. }
  73.  
  74. if (q2 == "exit")
  75. {
  76. cout << "Thanks for taking the quiz! Press Enter to exit\n";
  77. cin.ignore();
  78. cin.get();
  79. return 0;
  80. }
  81. string q3 = "";
  82. cout << "Question 1:\nWhich of the following is the correct operator to compare two variables?\n\n1 = '=='\n"
  83. << "2 = 'equal'\n3 = '='\n4 ="
  84. << " ':='\n" << endl;
  85. cin >> q3;
  86. cout << "\n" << endl;
  87.  
  88. if (q3 == "1")
  89. {
  90. a = 0;
  91. a = a + 1;
  92. }
  93.  
  94.  
  95. if (q3 == "exit")
  96. {
  97. cout << "Thanks for taking the quiz! Press Enter to exit\n";
  98. cin.ignore();
  99. cin.get();
  100. return 0;
  101. }
  102. string q4 = "";
  103. cout << "Question 4:\nWhich of the following is not a correct variable type?\n\n1 = real\n2 = int\n"
  104. << "3 = float\n4 = double\n" << endl;
  105. cin >> q4;
  106. cout << "\n" << endl;
  107.  
  108. if (q4 == "1")
  109. {
  110. a = a + 1;
  111. }
  112.  
  113. if (q4 == "exit")
  114. {
  115. cout << "Thanks for taking the quiz! Press Enter to exit\n";
  116. cin.ignore();
  117. cin.get();
  118. return 0;
  119. }
  120. string q5 = "";
  121. cout << "Question 5:\nWhat is the correct value to return the operating system upon the successful completion of a program?\n\n1 = -1\n2 = programs do not return a value\n3 = 0\n4 = 1\n" << endl;
  122. cin >> q5;
  123. cout << "\n" << endl;
  124.  
  125. if (q5 == "3")
  126. {
  127. a = a + 1;
  128. }
  129.  
  130. if (q5 == "exit")
  131. {
  132. cout << "Thanks for taking the quiz! Press Enter to exit\n";
  133. cin.ignore();
  134. cin.get();
  135. return 0;
  136. }
  137. string q6 = "";
  138. cout << "Question 6:\nWhich of these types can hold the largest number?\n\n1 = 'long'\n"
  139. << "2 = 'long double'\n3 = 'long float'\n4 ="
  140. << " 'int'\n" << endl;
  141. cin >> q6;
  142. cout << "\n" << endl;
  143.  
  144. if (q6 == "2")
  145. {
  146. a = 0;
  147. a = a + 1;
  148. }
  149.  
  150.  
  151. if (q6 == "exit")
  152. {
  153. cout << "Thanks for taking the quiz! Press Enter to exit\n";
  154. cin.ignore();
  155. cin.get();
  156. return 0;
  157. }
  158. string q7 = "";
  159. cout << "Question 7:\nWhat is similar but does not occupy memory like const?\n\n1 = #includes\n2 = char\n3 = const int\n4 = "
  160. << "#define\n" << endl;
  161. cin >> q7;
  162. cout << "\n" << endl;
  163.  
  164. if (q7 == "4")
  165. {
  166. a = a + 1;
  167. }
  168.  
  169. if (q7 == "exit")
  170. {
  171. cout << "Thanks for taking the quiz! Press Enter to exit\n";
  172. cin.ignore();
  173. cin.get();
  174. return 0;
  175. }
  176. string q8 = "";
  177. cout << "Question 8:\nWhat punctuation ends most lines of C++ code?\n\n1 = :\n2 = .\n3 = '\n4 = "
  178. << ";\n" << endl;
  179. cin >> q8;
  180. cout << "\n" << endl;
  181.  
  182. if (q8 == "4")
  183. {
  184. a = a + 1;
  185. }
  186.  
  187. if (q8 == "exit")
  188. {
  189. cout << "Thanks for taking the quiz! Press Enter to exit\n";
  190. cin.ignore();
  191. cin.get();
  192. return 0;
  193. }
  194. string q9 = "";
  195. cout << "Question 9:\nx=(y=(z=5)); What is the y value equal to?\n\n1 = 25\n2 = 5\n3 = 55\n4 = "
  196. << "10\n" << endl;
  197. cin >> q9;
  198. cout << "\n" << endl;
  199.  
  200. if (q9 == "2")
  201. {
  202. a = a + 1;
  203. }
  204.  
  205. if (q9 == "exit")
  206. {
  207. cout << "Thanks for taking the quiz! Press Enter to exit\n";
  208. cin.ignore();
  209. cin.get();
  210. return 0;
  211. }
  212. string q10 = "";
  213. cout << "Question 10:\nWhich one of these stream manipulators establishes a print field on n spaces\n\n1 = setw(1)\n2 = setprecision(n)\n3 = fixedpoint(n)\n4 = showpoint(n)\n" << endl;
  214. cin >> q10;
  215. cout << "\n" << endl;
  216.  
  217. if (q10 == "1")
  218. {
  219. a = a + 1;
  220. }
  221.  
  222. if (q10 == "exit")
  223. {
  224. cout << "Thanks for taking the quiz! Press Enter to exit\n";
  225. cin.ignore();
  226. cin.get();
  227. return 0;
  228. }
  229. s = a * 10;
  230.  
  231. if (s == 100)
  232. cout << "Congratulations! You got 100% of the answers right!\n" << endl;
  233.  
  234. else
  235. cout << "You answered " << s << "% of questions correct!\n" << endl;
  236.  
  237. cin.ignore();
  238. cin.get();
  239. return 0;
  240. }
  241. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement