Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Gameshow.cpp
- #include <iostream>
- int main() { // Begin main function.
- int answer;
- int finalScore = 0;
- void promptAndWait();
- // Greet the user and explain the game.
- std::cout << "Welcome to (Insert Gameshow Name Here)!'\n\n"
- << "In this game, you will be asked 5 questions.\n"
- << "You will be graded on your performance at the end.\n"
- << "Your performance will be represented as a percentile.\n"
- << "Each correct answer is worth 20% of the maximum percentage.\n"
- << "The maximum percentage possible is 100%.\n\n"
- << "To answer, type the number next to the corresponding option.\n"
- << "Do NOT type anything else.\n"
- << "Press Enter twice to get started!\n\n";
- promptAndWait();
- // Question #1.
- std::cout << "Question number one: What is the capital of Pennsylvania?\n\n"
- << "1. Harrisburg\n"
- << "2. Pittsburgh\n"
- << "3. Montgomery\n"
- << "4. Bismarck\n\n";
- std::cout<< "What is your answer?:";
- std::cin >> answer;
- if (answer == 1) { // Answered Harrisburg.
- std::cout << "Correct!\n\n";
- // Increase finalScore by 1.
- finalScore++;
- std::cout << "Press Enter for the next question.\n\n\n\n\n\n";
- } else { // Answered incorrectly.
- std::cout << "I'm sorry. The correct answer is 1. Harrisburg\n\n";
- std::cout << "Press Enter twice for the next question.\n\n\n\n\n\n";
- }
- promptAndWait();
- // Question #2.
- std::cout << "Question number 2: What is 2+2\n\n"
- << "1. Three\n"
- << "2. Four\n"
- << "3. Five\n"
- << "4. Six\n\n";
- std::cout<< "Enter your answer?:";
- std::cin >> answer;
- if (answer == 2) { // Answered Four.
- std::cout << "Correct!\n\n";
- // Increase finalScore by 1.
- finalScore++;
- std::cout << "Press Enter for the next question.\n\n\n\n\n\n";
- } else { // Answered incorrectly.
- std::cout << "I'm sorry. The correct answer is 2. Four\n\n";
- std::cout << "Press Enter for the next question.\n\n\n\n\n\n";
- }
- promptAndWait();
- // Question #3.
- std::cout << "Question number 3: What is the name of security expert Steve Gibson's\n"
- << "hard drive maintenance program?\n\n"
- << "1. SpinRite\n"
- << "2. SpinRight\n"
- << "3. TwirlRite\n"
- << "4. TwirlRight\n\n"
- << "Enter your answer: ";
- std::cin >> answer;
- if (answer == 1) { // Answered SpinRite.
- std::cout << "Correct!\n\n";
- // Increase finalScore by 1.
- finalScore++;
- std::cout << "Press Enter for the next question.\n\n\n\n\n\n";
- } else { // Answered incorrectly.
- std::cout << "I'm sorry. The correct answer is 1. SpinRite.\n\n"
- << "Press Enter for the next question.\n\n\n\n\n\n";
- }
- promptAndWait();
- // Question #4.
- std::cout << "Question number 4: What happens when Vince orders new computer parts?\n\n"
- << "1. The parts work perfectly\n"
- << "2. The parts fail catastrophically\n\n"
- << "Enter your answer: ";
- std::cin >> answer;
- if (answer == 2) { // Answered correctly.
- std::cout << "Correct!\n\n";
- // Increase finalScore by 1.
- finalScore++;
- std::cout << "Press Enter for the next question.\n\n\n\n\n\n";
- } else { // Answered incorrectly.
- std::cout << "I'm sorry. The answer is 2. The parts fail catastrophically.\n\n"
- << "Press Enter for the next question.\n\n\n\n\n\n";
- }
- promptAndWait();
- // Final Question.
- std::cout << "Final question: Whenever Caleb says anything, what happens?\n\n"
- << "1. The statment becomes true.\n"
- << "2. A person loses their job.\n"
- << "3. Caleb gets a dollar.\n"
- << "4. The statement becomes false.\n\n"
- << "Enter your answer: ";
- std::cin >> answer;
- if (answer == 4) {
- std::cout << "Correct!\n\n";
- // Increase finalScore by 1
- finalScore++;
- std::cout << "Press Enter to see your results!\n\n\n\n\n\n\n";
- } else {
- std::cout << "I'm sorry. The answer is 4. The statment becomes false.\n\n"
- << "Press Enter to see your results!\n\n";
- }
- promptAndWait();
- // Calculate Percent.
- int winPercent = (finalScore * 20);
- if (winPercent <=60) {
- std::cout << "Tough luck. Your final score is " << winPercent << "% \n\n";
- } else {
- std::cout << "Good job! Your final score is " << winPercent << "% \n\n";
- }
- system("PAUSE");
- return EXIT_SUCCESS;
- } // End of main function
- // Define the promptAndWait() function
- void promptAndWait() {
- std::cin.ignore(100, '\n');
- std::cin.get();
- } // End of the promptAndWait() function.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement