[ create a new paste ] login | about

Link: http://codepad.org/v7pnLoge    [ raw code | output | fork ]

pjvangemmeren - C++, pasted on Jun 13:
//A simple five-question quiz.
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
string name;
int score;
const char t = 1;
const char f = 0;
vector <string> perfectScores;
int main()
{
    cout << "\t\tWelcome to the quiz!\n";
    cout << "1. True or false: Bats are considered rodents (t/f)?\n";
    bool firstAnswer;
    const bool correct = 0;
    cin >> firstAnswer;
    if (firstAnswer == correct)
    {
        cout << "Correct!\n";
        score = 20;
    }
    else
    {
        cout << "Incorrect\n";
        score = 0;
    }
    cout << "2. True or false: Orcas are considered whales (t/f)?\n";
    bool secondAnswer;
    const bool correct2 = 0;
    cin >> secondAnswer;
    if (secondAnswer == correct2)
    {
        cout << "Correct!\n";
        score = (score + 20);
    }
    else
    {
        cout << "Incorrect\n";
    }
    cout << "3. True or false: Carbon's atomic number is 8 (t/f)?\n";
    bool thirdAnswer;
    const bool correct3 = 0;
    cin >> thirdAnswer;
    if (thirdAnswer == correct3)
    {
        cout << "Correct!\n";
        score = (score + 20);
    }
    else
    {
        cout << "Incorrect\n";
    }
    cout << "4. True or false: Hippopotamonstrosisquipsaliophobia is the fear of immensely long words (t/f)?\n";
    bool fourthAnswer;
    const bool correct4 = 1;
    cin >> fourthAnswer;
    if (fourthAnswer == correct4)
    {
        cout << "Correct!\n";
        score = (score + 20);
    }
    else
    {
        cout << "Incorrect\n";
    }
    cout << "Last question for double or nothing:\n";
    cout << "True or false: The word \'screeched\' is the longest monosyllabic word in the English language (t/f)?\n";
    bool finalAnswer;
    const bool correct5 = 1;
    cin >> finalAnswer;
    if (finalAnswer == correct5)
    {
        cout << "CORRECT!\n";
        score = (score + score);
    }
    else
    {
        cout << "You lost it all.";
    }
    cout << "\n\n\t\tYour final score is:\n\n\t\t\t" << score << "\n";
    cout << "\n1.Play again\n2.View perfect scores\n3.Quit\nEnter the number of your choice:\n";
    int choice;
    const int play = 1;
    const int view = 2;
    const int exit = 3;
    cin >> choice;
    if (choice == play)
    {
    return 1;
    }
    else if (choice == view)
    {
        cout << perfectScores<< "\n1. Play again\n3. Quit\n";
        cin >> choice;
    return 94;
    }
    else if (choice == 3)
    {
        cout << endl;
        cout << "\n\n\t\tGoodbye!\a";
    return 0;
    }
    if (score == 160)
    {
        if (score == 160)
        {
            cout << "Enter your name and press enter.\n";
            cin >> name;
            perfectScores.push_back(name);
            cout << "\n\t\tCongratulations!\n";
            cout << "\n1.Play again\n2.View perfect scores\n3.Quit\nEnter the number of your choice:\n";
            int choice;
            const int play = 1;
            const int view = 2;
            const int exit = 3;
            cin >> choice;
        if (choice == play)
        {
        return 1;
        }
        else if (choice == view)
        {
            cout << perfectScores<< "\n1. Play again\n3. Quit\n";
            cin >> choice;
    return 94;
    }
    else if (choice == 3)
    {
        cout << endl;
        cout << "\n\n\t\tGoodbye!\a";
    return 0;
    }

        }
    return 0;
    }
}


Output:
		Welcome to the quiz!
1. True or false: Bats are considered rodents (t/f)?
Incorrect
2. True or false: Orcas are considered whales (t/f)?
Incorrect
3. True or false: Carbon's atomic number is 8 (t/f)?
Incorrect
4. True or false: Hippopotamonstrosisquipsaliophobia is the fear of immensely long words (t/f)?
Correct!
Last question for double or nothing:
True or false: The word 'screeched' is the longest monosyllabic word in the English language (t/f)?
CORRECT!


		Your final score is:

			40

1.Play again
2.View perfect scores
3.Quit
Enter the number of your choice:


Create a new paste based on this one


Comments: