Guest User

First C++ program -- 5 question quiz

a guest
Dec 6th, 2012
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.19 KB | None | 0 0
  1. /* HEADERS */
  2.  
  3. #include <iostream>
  4. #include <conio.h>
  5. #include <windows.h>
  6. #include <cmath>
  7. #include <string>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.     system("COLOR 07");
  14.  
  15.     char personsName[80];
  16.     cout << "Before we begin, what is your name? " << endl;
  17.     cin >> personsName;
  18.     system("CLS");
  19.  
  20.  
  21.  
  22.     Sleep(30);
  23.     cout << "                                H";
  24.     Sleep(30);
  25.     cout << "e";
  26.     Sleep(30);
  27.     cout << "l";
  28.     Sleep(30);
  29.     cout << "l";
  30.     Sleep(30);
  31.     cout << "o";
  32.     Sleep(30);
  33.     cout << ",";
  34.     Sleep(30);
  35.     cout << " ";
  36.     Sleep(30);
  37.     cout << personsName;
  38.     Sleep(30);
  39.     cout << ".";
  40.     Sleep(700);
  41.     cout << endl;
  42.     Sleep(30);
  43.     cout << "                                I";
  44.     Sleep(30);
  45.     cout << "'";
  46.     Sleep(30);
  47.     cout << "m ";
  48.     Sleep(30);
  49.     cout << "a ";
  50.     Sleep(30);
  51.     cout << "c";
  52.     Sleep(30);
  53.     cout << "o";
  54.     Sleep(30);
  55.     cout << "m";
  56.     Sleep(30);
  57.     cout << "p";
  58.     Sleep(30);
  59.     cout << "u";
  60.     Sleep(30);
  61.     cout << "t";
  62.     Sleep(30);
  63.     cout << "e";
  64.     Sleep(30);
  65.     cout << "r";
  66.     Sleep(30);
  67.     cout << ".";
  68.     Sleep(3500);
  69.  
  70.  
  71.  
  72.     system("CLS");
  73.     system("COLOR 06");
  74.  
  75.  
  76.     cout << endl << endl << endl << endl << endl;
  77.     Sleep(100);
  78.     cout << "     I ";
  79.     Sleep(100);
  80.     cout << "will ";
  81.     Sleep(100);
  82.     cout << "count ";
  83.     Sleep(100);
  84.     cout << "down ";
  85.     Sleep(100);
  86.     cout << "from ";
  87.     Sleep(100);
  88.     cout << "5, ";
  89.     Sleep(100);
  90.     cout << "and ";
  91.     Sleep(100);
  92.     cout << "when ";
  93.     Sleep(100);
  94.     cout << "I ";
  95.     Sleep(100);
  96.     cout << "get ";
  97.     Sleep(100);
  98.     cout << "to ";
  99.     Sleep(100);
  100.     cout << "0, ";
  101.     Sleep(100);
  102.     cout << "the ";
  103.     Sleep(100);
  104.     cout << "quiz ";
  105.     Sleep(100);
  106.     cout << "will ";
  107.     Sleep(100);
  108.     cout << "begin. ";
  109.     cout << endl << endl;
  110.     Sleep(100);
  111.     cout << "You ";
  112.     Sleep(100);
  113.     cout << "will ";
  114.     Sleep(100);
  115.     cout << "be ";
  116.     Sleep(100);
  117.     cout << "asked ";
  118.     Sleep(100);
  119.     cout << "five ";
  120.     Sleep(100);
  121.     cout << "questions. ";
  122.     Sleep(100);
  123.     cout << "Answer ";
  124.     Sleep(100);
  125.     cout << "them ";
  126.     Sleep(100);
  127.     cout << "correctly ";
  128.     Sleep(100);
  129.     cout << "or ";
  130.     Sleep(100);
  131.     cout << "you ";
  132.     Sleep(100);
  133.     cout << "must ";
  134.     Sleep(100);
  135.     cout << "repeat ";
  136.     Sleep(100);
  137.     cout << "the ";
  138.     cout << endl << endl;
  139.     Sleep(100);
  140.     cout << "                            question. ";
  141.     Sleep(100);
  142.     cout << "GOOD ";
  143.     Sleep(100);
  144.     cout << "LUCK ";
  145.     Sleep(100);
  146.     cout << "!";
  147.     Sleep(5000);
  148.  
  149.     system("CLS");
  150.  
  151.     char y;
  152.     char n;
  153.     char z;
  154.     int a;
  155.     int b;
  156.     int c;
  157.     int d;
  158.     int e;
  159.  
  160.  
  161. system("COLOR 80");
  162.     cout << endl << endl << endl << endl << endl;
  163.     cout <<"                     *                                     *"<< endl;
  164.     cout << "                      You will have endless time to answer." << endl;
  165.     cout <<"                     *                                     *"<< endl;
  166.     cout << "                      Are you ready? Enter y for yes, n no." << endl;
  167.     cout << "                                        ";
  168.  
  169. do
  170. {
  171.         cin >> z;
  172.     if ( z == 'y' )
  173.     {
  174.         system("CLS");
  175.  
  176.  
  177.     /* COUNTDOWN */
  178.  
  179.  
  180.     cout << endl << endl << endl << endl << endl << endl << endl << endl << endl;;
  181.     cout << "                                      FIVE";
  182.     Sleep(1000);
  183.     system("CLS");
  184.     cout << endl << endl << endl << endl << endl << endl << endl << endl << endl;
  185.     cout << "                                      FOUR";
  186.     Sleep(1000);
  187.     system("CLS");
  188.     cout << endl << endl << endl << endl << endl << endl << endl << endl << endl;
  189.     cout << "                                      THREE";
  190.     Sleep(1000);
  191.     system("CLS");
  192.     cout << endl << endl << endl << endl << endl << endl << endl << endl << endl;
  193.     cout << "                                      TWO";
  194.     Sleep(1000);
  195.     system("CLS");
  196.     cout << endl << endl << endl << endl << endl << endl << endl << endl << endl;
  197.     cout << "                                      ONE";
  198.     Sleep(1000);
  199.     system("CLS");
  200.     cout << endl << endl << endl << endl << endl << endl << endl << endl << endl;
  201.     cout << "                                      ...";
  202.     Sleep(1000);
  203.     system("CLS");
  204.  
  205.  
  206.  
  207.     /* THE QUESTIONS */
  208.  
  209.  
  210.     cout << "QUESTION 1: How many fingers do you have?" << endl;
  211.     do{
  212.  
  213.     cin >> a;
  214.  
  215.     if (a == 10)
  216.     {
  217.         cout << "Correct, on to question 2." << endl;
  218.         Sleep(2000);
  219.         system("CLS");
  220.     }
  221.  
  222.     else
  223.     {
  224.         cout << "Silly, you're a human not an alien! Think again." << endl;
  225.     }
  226.  
  227.     } while (a != 10);
  228.  
  229.  
  230.     /* ******************************************************** */
  231.  
  232.     cout << "QUESTION 2: What is the sum of 17 and 33?" << endl;
  233.  
  234.     do{
  235.  
  236.     cin >> b;
  237.  
  238.     if (b == 50)
  239.     {
  240.         cout << "Correct, on to question 3." << endl;
  241.         Sleep(2000);
  242.         system("CLS");
  243.     }
  244.  
  245.     else
  246.     {
  247.         cout << "Back to 1st grade.. guess again." << endl;
  248.     }
  249.  
  250.     } while (b != 50);
  251.  
  252.     /* ******************************************************** */
  253.  
  254.     cout << "QUESTION 3: If x = 7, and y = -3, what is x + y?" << endl;
  255.  
  256.     do{
  257.  
  258.     cin >> c;
  259.  
  260.     if (c == 4)
  261.     {
  262.         cout << "Correct, on to question 4." << endl;
  263.         Sleep(2000);
  264.         system("CLS");
  265.     }
  266.  
  267.     else
  268.     {
  269.         cout << "Really.. thats so simple.. go again." << endl;
  270.     }
  271.  
  272.     } while (c != 4);
  273.  
  274.     /* ******************************************************** */
  275.  
  276.     cout << "QUESTION 4: How many planets are in our Solar System?" << endl;
  277.  
  278.     do{
  279.  
  280.     cin >> d;
  281.  
  282.     if (d == 9)
  283.     {
  284.         cout << "Correct, on to question 5." << endl;
  285.         Sleep(2000);
  286.         system("CLS");
  287.     }
  288.  
  289.     else
  290.     {
  291.         cout << "Tsk tsk tsk! Study harder.. try again." << endl;
  292.     }
  293.  
  294.     } while (d != 9);
  295.  
  296.     /* ******************************************************** */
  297.  
  298.     cout << "QUESTION 2: How old are you?" << endl;
  299.  
  300.     do{
  301.     cin >> e;
  302.     e = e;
  303.  
  304.  
  305.     if (e > 25)
  306.  
  307.         cout << "You're not THAT old.. " << endl;
  308.  
  309.     else if (e < 12)
  310.  
  311.         cout << "You're wayyy older than that! " << endl;
  312.  
  313.     else
  314.         {
  315.             cout << "You ARE " << e << " years old!" << endl;
  316.         Sleep(2000);
  317.         system("CLS");
  318.  
  319.             /* ENDING */
  320.  
  321.     cout << "                  ------------------------------------------------     " << endl
  322.          << "                /                                               /      " << endl
  323.          << "               | This was my first ever program made using C++ |       " << endl
  324.          << "               | programming language! I hopy you enjoyed it   |       " << endl
  325.          << "               | as much as I enjoyed making it! I have aspir- |       " << endl
  326.          << "               | ations to major in Computer Science after I   |       " << endl
  327.          << "               | graduate from High School and go off to Univ- |       " << endl
  328.          << "               | ersity. Programming is very intriguing... Be  |       " << endl
  329.          << "               | prepared to see many more videos in the future|       " << endl
  330.          << "               | with bigger more complex programs aswell. This|       " << endl
  331.          << "               | was my first, so dont hate. cout << 'THE END';|       " << endl
  332.          << "              /                                               /        " << endl
  333.          << "             ------------------------------------------------          " << endl;
  334.  
  335.         }
  336.  
  337.  
  338.  
  339.     } while (e != 13 || e != 14 || e != 15 || e != 16 || e != 17 || e != 18 || e != 19 || e != 20 || e != 21 || e != 22 || e != 23 || e != 24 || e != 25);
  340.  
  341.  
  342.     }
  343.  
  344.     else if ( z == 'n' )
  345.     {
  346.         system("CLS");
  347.         cout << "Thats okay, I'll wait. Type in y when you're ready!" << endl;
  348.  
  349.  
  350.     }
  351.     else
  352.     {
  353.         system("CLS");
  354.         cout << "I said enter y or n, silly!" << endl;
  355.  
  356.  
  357.     }
  358. } while ( z != 'y' || z != 'n' );
  359.  
  360.  
  361. return 0;
  362. }
Advertisement
Add Comment
Please, Sign In to add comment