Guest User

test

a guest
Nov 1st, 2016
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 11.11 KB | None | 0 0
  1. //Jason and Kevin
  2. #include <iostream>
  3. #include <string>
  4. #include <iomanip>
  5. #include <random>
  6. #include <limits>
  7. #include <ios>
  8.  
  9. using namespace std;
  10.  
  11. int score = 0;
  12.  
  13. string q;
  14.  
  15. void end() { // ending function
  16.     cout << "===============================\n"
  17.          << "Your Final score is " << score << "/10" //prints score
  18.          << " or " << (score * 10) << "%\n" // Multiplies by 10 to get percent
  19.          << "===============================\n";
  20.          exit(0); // ends
  21. }
  22.  
  23. void question10() { //comments for questions below:
  24.     cout << "\nQuestion 10:\n"
  25.          << "Which member of Monty Python is dead?\n"
  26.          << "a) Eric Idle\n"
  27.          << "b) Graham Chapman\n"
  28.          << "c) John Cleese\n"
  29.          << "d) Terry Jones\n\n"
  30.          << "Your awnser: ";
  31.          
  32.     cin >> q;
  33.    
  34.     if (q == "b") {
  35.         cout << "\nCORRECT!\n";
  36.         score += 1;
  37.         cout << "----------------------------------------\n";
  38.         cout << "Your score is: " << score << " out of 10\n";
  39.         cout << "----------------------------------------\n";
  40.     }
  41.     else {
  42.         cout << "\nWRONG. The correct awnser is: B\n"
  43.              << "----------------------------------------\n"
  44.              << "Your score is: " << score << " out of 10\n"
  45.              << "----------------------------------------\n";
  46.     }
  47.    
  48.          
  49.     end();
  50. }
  51.  
  52. void question9() {
  53.     cout << "\nQuestion 9:\n"
  54.          << "The evil villan Andross is a: \n"
  55.          << "a) Monkey\n"
  56.          << "b) Crocodile\n"
  57.          << "c) Tiger\n"
  58.          << "d) Pig\n\n"
  59.          << "Your awnser: ";
  60.          
  61.     cin >> q;
  62.    
  63.     if (q == "a") {
  64.         cout << "\nCORRECT!\n";
  65.         score += 1;
  66.         cout << "----------------------------------------\n";
  67.         cout << "Your score is: " << score << " out of 10\n";
  68.         cout << "----------------------------------------\n";
  69.     }
  70.     else {
  71.         cout << "\nWRONG. The correct awnser is: A\n"
  72.              << "----------------------------------------\n"
  73.              << "Your score is: " << score << " out of 10\n"
  74.              << "----------------------------------------\n";
  75.     }
  76.    
  77.          
  78.     question10();
  79. }
  80.  
  81. void question8() {
  82.     cout << "\nQuestion 8:\n"
  83.          << "What is 666th Pokémon in the National Pokédex?\n"
  84.          << "a) Talon Flame\n"
  85.          << "b) Persian\n"
  86.          << "c) Flareon\n"
  87.          << "d) Vivillon\n\n"
  88.          << "Your awnser: ";
  89.          
  90.     cin >> q;
  91.    
  92.     if (q == "d") {
  93.         cout << "\nCORRECT!\n";
  94.         score += 1;
  95.         cout << "----------------------------------------\n";
  96.         cout << "Your score is: " << score << " out of 10\n";
  97.         cout << "----------------------------------------\n";
  98.     }
  99.     else {
  100.         cout << "\nWRONG. The correct awnser is: D\n"
  101.              << "----------------------------------------\n"
  102.              << "Your score is: " << score << " out of 10\n"
  103.              << "----------------------------------------\n";
  104.     }
  105.    
  106.          
  107.     question9();
  108. }
  109.  
  110. void question7() {
  111.     cout << "\nQuestion 7:\n"
  112.          << "What material is Dark Samus made of?\n"
  113.          << "a) Adaptanium\n"
  114.          << "b) Uridium\n"
  115.          << "c) Phazon\n"
  116.          << "d) Cromainium\n\n"
  117.          << "Your awnser: ";
  118.          
  119.     cin >> q;
  120.    
  121.     if (q == "c") {
  122.         cout << "\nCORRECT!\n";
  123.         score += 1;
  124.         cout << "----------------------------------------\n";
  125.         cout << "Your score is: " << score << " out of 10\n";
  126.         cout << "----------------------------------------\n";
  127.     }
  128.     else {
  129.         cout << "\nWRONG. The correct awnser is: C\n"
  130.              << "----------------------------------------\n"
  131.              << "Your score is: " << score << " out of 10\n"
  132.              << "----------------------------------------\n";
  133.     }
  134.    
  135.          
  136.     question8();
  137. }
  138.  
  139. void question6() {
  140.     cout << "\nQuestion 6:\n"
  141.          << "What is the relationship between the ICE CLIMBERS?\n"
  142.          << "a) Brother and Sister\n"
  143.          << "b) Husband and Wife\n"
  144.          << "c) Boyfriend and girlfriend\n"
  145.          << "d) Nephew and Aunt\n\n"
  146.          << "Your awnser: ";
  147.          
  148.     cin >> q;
  149.    
  150.     if (q == "d") {
  151.         cout << "\nCORRECT!\n";
  152.         score += 1;
  153.         cout << "----------------------------------------\n";
  154.         cout << "Your score is: " << score << " out of 10\n";
  155.         cout << "----------------------------------------\n";
  156.     }
  157.     else {
  158.         cout << "\nWRONG. The correct awnser is: D\n"
  159.              << "----------------------------------------\n"
  160.              << "Your score is: " << score << " out of 10\n"
  161.              << "----------------------------------------\n";
  162.     }
  163.    
  164.          
  165.     question7();
  166. }
  167.  
  168. void question5() {
  169.     cout << "\nQuestion 5:\n"
  170.          << "What philosophical thoery is present in Bioshock?\n"
  171.          << "a) Objectivism\n"
  172.          << "b) Dawrinism\n"
  173.          << "c) virtue Ethic\n"
  174.          << "d) Utilitarianism\n\n"
  175.          << "Your awnser: ";
  176.          
  177.     cin >> q;
  178.    
  179.     if (q == "a") {
  180.         cout << "\nCORRECT!\n";
  181.         score += 1;
  182.         cout << "----------------------------------------\n";
  183.         cout << "Your score is: " << score << " out of 10\n";
  184.         cout << "----------------------------------------\n";
  185.     }
  186.     else {
  187.         cout << "\nWRONG. The correct awnser is: A\n"
  188.              << "----------------------------------------\n"
  189.              << "Your score is: " << score << " out of 10\n"
  190.              << "----------------------------------------\n";
  191.     }
  192.    
  193.          
  194.     question6();
  195. }
  196.  
  197.  
  198. void question4() {
  199.     cout << "\nQuestion 4:\n"
  200.          << "What is the #1 selling game of all time?\n"
  201.          << "a) GTA V\n"
  202.          << "b) Wii sports\n"
  203.          << "c) The Witcher 3\n"
  204.          << "d) Super Mario Bros\n\n"
  205.          << "Your awnser: ";
  206.          
  207.     cin >> q;
  208.    
  209.     if (q == "b") {
  210.         cout << "\nCORRECT!\n";
  211.         score += 1;
  212.         cout << "----------------------------------------\n";
  213.         cout << "Your score is: " << score << " out of 10\n";
  214.         cout << "----------------------------------------\n";
  215.     }
  216.     else {
  217.         cout << "\nWRONG. The correct awnser is: B\n"
  218.              << "----------------------------------------\n"
  219.              << "Your score is: " << score << " out of 10\n"
  220.              << "----------------------------------------\n";
  221.     }
  222.    
  223.          
  224.     question5();
  225. }
  226.  
  227. void question3() {
  228.     cout << "\nQuestion 3:\n"
  229.          << "How many levels are in Super Mario World's star world??\n"
  230.          << "a) 3\n"
  231.          << "b) 4\n"
  232.          << "c) 5\n"
  233.          << "d) 6\n\n"
  234.          << "Your awnser: ";
  235.          
  236.     cin >> q;
  237.    
  238.     if (q == "c") {
  239.         cout << "\nCORRECT!\n";
  240.         score += 1;
  241.         cout << "----------------------------------------\n";
  242.         cout << "Your score is: " << score << " out of 10\n";
  243.         cout << "----------------------------------------\n";
  244.     }
  245.     else {
  246.         cout << "\nWRONG. The correct awnser is: C\n"
  247.              << "----------------------------------------\n"
  248.              << "Your score is: " << score << " out of 10\n"
  249.              << "----------------------------------------\n";
  250.     }
  251.    
  252.          
  253.     question4();
  254. }
  255.  
  256. void question2() {
  257.     cout << "\nQuestion 2:\n"
  258.          << "What is the name of Links boat in the wind waker?\n"
  259.          << "a) The Red tiger\n"
  260.          << "b) Sail of Hyrule\n"
  261.          << "c) king of red ganon\n"
  262.          << "d) King of red lions\n\n"
  263.          << "Your awnser: ";
  264.          
  265.     cin >> q;
  266.    
  267.     if (q == "d") {
  268.         cout << "\nCORRECT!\n";
  269.         score += 1;
  270.         cout << "----------------------------------------\n";
  271.         cout << "Your score is: " << score << " out of 10\n";
  272.         cout << "----------------------------------------\n";
  273.     }
  274.     else {
  275.         cout << "\nWRONG. The correct awnser is: d\n"
  276.              << "----------------------------------------\n"
  277.              << "Your score is: " << score << " out of 10\n"
  278.              << "----------------------------------------\n";
  279.     }
  280.    
  281.          
  282.     question3();
  283. }
  284.  
  285. void question1() {  // Each function is a question
  286.    
  287.     cout << "--------------------\n"
  288.          << "        TEST        \n"
  289.          << "--------------------\n\n";
  290.          
  291.     cout << "Question 1:\n"
  292.          << "Where is Kirby from?\n"
  293.          << "a) Candy land\n"
  294.          << "b) Kloud Kingdom\n"
  295.          << "c) Dream land\n"
  296.          << "d) Robotnic's Kingdom\n\n"
  297.          << "Your awnser: ";
  298.          
  299.     cin >> q;  // inouts awnser
  300.    
  301.     if (q == "c") { // If the input is the correct awnser
  302.         cout << "\nCORRECT!\n";
  303.         score += 1; // adds one to correct counter
  304.         cout << "----------------------------------------\n";
  305.         cout << "Your score is: " << score << " out of 10\n";
  306.         cout << "----------------------------------------\n";
  307.     }
  308.     else { // else it will not add anything
  309.         cout << "\nWRONG. The correct awnser is: C\n"
  310.              << "----------------------------------------\n"
  311.              << "Your score is: " << score << " out of 10\n"
  312.              << "----------------------------------------\n";
  313.     }
  314.    
  315.          
  316.     question2(); //Goes to next question and it is the same for rest
  317. }
  318.  
  319.  
  320. int main() {
  321.     string arr [] = {"Jason","Kevin"}; //Usernames in system
  322.     string username, password, jasonPassword = "password", kevinPassword = "password";
  323.     int x, userpass;
  324.     cout << "-----------Test Tron------------\n"
  325.          << "Enter test username and password\n"
  326.          << "--------------------------------\n"
  327.          << "Username: ";
  328.          cin >> username;
  329.          
  330.          
  331.     for (x = 0 ; x < 2 ; x++) { //for loop
  332.         if (username == arr[x]) { //checks if the username is in any spot of the array
  333.             cout << "\nWelcome " << username << "\n";
  334.             if (username == arr[0]) {
  335.                 userpass = 1;
  336.             }
  337.             break;
  338.         }
  339.         if (x == 1) {
  340.             cout << "User name not found. Please try again";
  341.             exit(0);
  342.         }
  343.     }
  344.     cout << "\n" << "Your Password: "; //asks for password
  345.    
  346.     if (userpass == 1) { //password for me as added to counter before
  347.         for (x = 0 ; x < 5 ; x++) {
  348.             cin >> password; //inputs password
  349.             if (password == jasonPassword) { //Checks if eqaul to my password
  350.                 question1(); //if so, starts questions
  351.             }
  352.             else {
  353.                 cout << "Incorrect password try again: "; //Trys again until 5 attemps are up
  354.             }
  355.         }
  356.     cout << "\nToo many tries, you are locked out"; //locks out after 5
  357.     }
  358.     else {
  359.         for (x = 0 ; x < 5 ; x++) { //same for kevin
  360.             cin >> password;
  361.             if (password == kevinPassword) {
  362.                 question1();
  363.             }
  364.             else {
  365.                 cout << "Incorrect password try again: ";
  366.             }
  367.         }
  368.     cout << "\nToo many tries, you are locked out";
  369.     }
  370. }
Add Comment
Please, Sign In to add comment