Advertisement
7uzu7maki7

Mathematical game

Jun 22nd, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. // ConsoleApplication2.cpp : Defines the entry point for the console application.
  2.  
  3. // Rihards Heinerihs Sakalis
  4.  
  5.  
  6.  
  7.  
  8.  
  9. /*UNIT 16 Assignment 2*/
  10.  
  11. #include "stdafx.h"
  12.  
  13. #include <iostream>
  14.  
  15. #include <string>
  16.  
  17.  
  18.  
  19. using namespace std;
  20.  
  21.  
  22.  
  23. int main()
  24.  
  25. {
  26.  
  27.  
  28.  
  29. /*Welcoming screen*/
  30.  
  31. cout << "///////////////////////////////////////////////////////////////////////////////// \n\n";
  32.  
  33. cout << " \n\n ";
  34.  
  35. cout << " Welcome to the Maths game! \n\n";
  36.  
  37. cout << " \n\n";
  38.  
  39. cout << "///////////////////////////////////////////////////////////////////////////////// \n\n";
  40.  
  41.  
  42.  
  43. system("pause");
  44.  
  45. system("cls");
  46.  
  47.  
  48.  
  49. int ans;
  50.  
  51. int score = 0; //This is used to create a score system
  52.  
  53. string username;
  54.  
  55. string password;
  56.  
  57. bool success;
  58.  
  59. cout << "\tWelcome, please type in the login details to proceed. The guest's login - Username = guest Password = guest\n\n";
  60.  
  61.  
  62.  
  63. do
  64.  
  65. {
  66.  
  67. cout << endl << "Username: ";
  68.  
  69. cin >> username;
  70.  
  71. cout << endl << "Password: ";
  72.  
  73. cin >> password;
  74.  
  75.  
  76.  
  77. if (username == "rihard" && password == "sakalis") // My personal Login
  78.  
  79. {
  80.  
  81. cout << endl << "Hey, Rihard's, ";
  82.  
  83. success = true;
  84.  
  85. }
  86.  
  87.  
  88.  
  89. else if (username == "guest" && password == "guest")// Login for a guest
  90.  
  91. {
  92.  
  93. cout << endl << "Welcome, Guest, ";
  94.  
  95. success = true;
  96.  
  97. }
  98.  
  99.  
  100.  
  101. else
  102.  
  103. {
  104.  
  105. cout << endl << "your login failed."; // If you fail to input the correct details, this message will display.
  106.  
  107. success = false;
  108.  
  109. }
  110.  
  111. } while (!success);
  112.  
  113.  
  114. system("pause");
  115.  
  116. system("cls");
  117.  
  118. {
  119. cout << " You will have 7 questions to answer, do not use the calculator!, Good luck \n";
  120. }
  121. cout << "One more thing before you start, remember to do the Multiplications / Dividing first - BIDMAS!\n\n";
  122.  
  123. cout << "1) 3 + 3 * 3 = "; // Question you have to answer.
  124.  
  125. cin >> ans;
  126.  
  127.  
  128.  
  129. if (ans == 12) //This is the correct answer to the qeustion, if he answers it correctly he gets an extra point.
  130.  
  131. {
  132.  
  133. ++score;
  134.  
  135. cout << "Nice! You gained an extra point! " << score << endl << endl; // - The extra pooint ^
  136.  
  137. }
  138.  
  139. else
  140.  
  141. {
  142.  
  143. cout << "Wrong answer. Your current score is: " << score << endl << endl;
  144.  
  145. }
  146.  
  147.  
  148.  
  149. cout << "2) 26 + 3 * 8 = ";
  150.  
  151. cin >> ans;
  152.  
  153.  
  154.  
  155. if (ans == 50)
  156.  
  157. {
  158.  
  159. ++score;
  160.  
  161. cout << "Nice! You gained an extra point! " << score << endl << endl;
  162.  
  163. }
  164.  
  165. else
  166.  
  167. {
  168.  
  169. cout << "Wrong answer. Your current score is: " << score << endl << endl;
  170.  
  171. }
  172.  
  173.  
  174.  
  175. cout << "3) 9 + 77 / 7 = ";
  176.  
  177. cin >> ans;
  178.  
  179.  
  180.  
  181. if (ans == 20)
  182.  
  183. {
  184.  
  185. ++score;
  186.  
  187. cout << "Nice! You gained an extra point! " << score << endl << endl;
  188.  
  189. }
  190.  
  191. else
  192.  
  193. {
  194.  
  195. cout << "Wrong answer. Your current score is: " << score << endl << endl;
  196.  
  197. }
  198.  
  199.  
  200.  
  201. cout << "4) 33 + 22 + 11 = ";
  202.  
  203. cin >> ans;
  204.  
  205.  
  206.  
  207. if (ans == 66)
  208.  
  209. {
  210.  
  211. ++score;
  212.  
  213. cout << "Nice! You gained an extra point! " << score << endl << endl;
  214.  
  215. }
  216.  
  217. else
  218.  
  219. {
  220.  
  221. cout << "Wrong answer. Your current score is: " << score << endl << endl;
  222.  
  223. }
  224.  
  225.  
  226.  
  227. cout << "5) 12 * 20 = ";
  228.  
  229. cin >> ans;
  230.  
  231.  
  232.  
  233. if (ans == 240)
  234.  
  235. {
  236.  
  237. ++score;
  238.  
  239. cout << "Nice! You gained an extra point! " << score << endl << endl;
  240.  
  241. }
  242.  
  243. else
  244.  
  245. {
  246.  
  247. cout << "Wrong answer. Your current score is: " << score << endl << endl;
  248.  
  249. }
  250.  
  251.  
  252.  
  253. cout << "6) 7 * 2 + 10 = ";
  254.  
  255. cin >> ans;
  256.  
  257.  
  258.  
  259. if (ans == 24)
  260.  
  261. {
  262.  
  263. ++score;
  264.  
  265. cout << "Nice! You gained an extra point! " << score << endl << endl;
  266.  
  267. }
  268.  
  269. else
  270.  
  271. {
  272.  
  273. cout << "Wrong answer. Your current score is: " << score << endl << endl;
  274.  
  275. }
  276.  
  277.  
  278.  
  279. cout << "7) 420 - 377 = ";
  280.  
  281. cin >> ans;
  282.  
  283.  
  284.  
  285. if (ans == 43)
  286.  
  287. {
  288.  
  289. ++score;
  290.  
  291. cout << "Nice! You gained an extra point! " << score << endl << endl;
  292.  
  293. }
  294.  
  295. else
  296.  
  297. {
  298.  
  299. cout << "You answered the question wrong. Your final score is: " << score << endl << endl;
  300.  
  301. }
  302.  
  303. cout << "Thanks for playing my game, ";
  304.  
  305. system("pause");
  306.  
  307. return 0;
  308.  
  309.  
  310.  
  311. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement