This is how far I went with the program. The code below only let the user take the test as much as they want, and tell them how many times they took it, and the last score they had. My idea is this, if I can make a variable store each test score, then I can compare them. But since there is no definite number of tests to be taken, I think I'ld need a loop. Please help.
Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <string>
- using namespace std;
- void main()
- {
- int correct = 0;
- int wrong = 0;
- int count = 0;
- string choice;
- string ans;
- cout << "\t\t\t Principles of Macroeconomics (ECO 201)\n";
- cout << "\t\t\t****************************************\n";
- cout << "\t\t\t\t\t Test Exam\n";
- cout << "\t\t\t\t\t***********\n\n\n";
- while (true)
- {
- while (true)
- {
- cout << "Multiple Choice: 2 points each\n\n";
- cout << "Enter each answer using a....e\n\n";
- cout << "1. In economics, choices are necessary because of the presence of:\n";
- cout << "\ta. luxuries\n";
- cout << "\tb. inefficiency\n";
- cout << "\tc. needs\n";
- cout << "\td. scarcity\n";
- cout << "\te. incentives\n";
- cout << "Answer: ";
- cin >> choice;
- if (choice == "d")
- {
- correct++;
- cout << "Correct: Scarcity\n\n\n";
- break;
- }
- else
- if ((choice >= "a" && choice <= "c") || (choice >= "e" && choice <= "e"))
- {
- wrong++;
- cout << "\aWrong!!!\n\n\n";
- break;
- }
- else
- if ((choice >= "f" || choice <= "z"))
- {
- cout << "Wrong input! Your input is out of range!\n\n";
- cout << "Do you want to try again?\n\nEnter any letter to continue or \"n\" to exit the program\n";
- cin >> ans;
- if (ans == "n")
- {
- break;
- }
- }
- }
- while (true)
- {
- cout << "2. Assumptions are necessary to build a good economic model\n";
- cout << "\ta. True\n";
- cout << "\tb. False\n";
- cout << "Answer: ";
- cin >> choice;
- if (choice == "a" || choice == "true")
- {
- correct++;
- cout << "True: Assumptions are necessary to build a good economic model\n\n\n";
- break;
- }
- else
- if (choice == "b" || choice == "false")
- {
- wrong++;
- cout << "\aWrong!!!\n\n\n";
- break;
- }
- else
- if ((choice >= "c" || choice <= "z"))
- {
- cout << "Wrong input! Your input is out of range!\n\n";
- cout << "Do you want to try again?\n\nEnter any letter to continue or \"n\" to exit the program\n";
- cin >> ans;
- if (ans == "n")
- {
- break;
- }
- }
- }
- while (true)
- {
- cout << "3. Economics is the study of: \n";
- cout << "\ta. how to make money\n";
- cout << "\tb. how to allocate resources to satisfy wants and needs\n";
- cout << "\tc. capitalism\n";
- cout << "\td. how to make workers more productive and firms more profitable\n";
- cout << "\te. markets\n";
- cout << "Answer: ";
- cin >> choice;
- if (choice == "b")
- {
- correct++;
- cout << "Correct: How to allocate resources to satisfy wants and needs\n\n\n";
- break;
- }
- else
- if ((choice >= "a" && choice <= "a") || (choice >= "c" && choice <= "e"))
- {
- wrong++;
- cout << "\aWrong!!!\n\n\n";
- break;
- }
- else
- if ((choice >= "f" || choice <= "z"))
- {
- cout << "Wrong input! Your input is out of range!\n\n";
- cout << "Do you want to try again?\n\nEnter any letter to continue or \"n\" to exit the program\n";
- cin >> ans;
- if (ans == "n")
- {
- break;
- }
- }
- }
- while (true)
- {
- cout << "4. Which of the following is true?\n";
- cout << "\ta. unaccounted variables in a model are called endogenous factors\n";
- cout << "\tb. unaccounted variables in a model are called exogenous factors\n";
- cout << "Answer: ";
- cin >> choice;
- if (choice == "b")
- {
- correct++;
- cout << "Correct: Unaccounted variables in a model are called exogenous factors\n\n\n";
- break;
- }
- else
- if ((choice >= "a" && choice <= "a") || (choice >= "c" && choice <= "e"))
- {
- wrong++;
- cout << "\aWrong!!!\n\n\n";
- break;
- }
- else
- if ((choice >= "f" || choice <= "z"))
- {
- cout << "Wrong input! Your input is out of range!\n\n";
- cout << "Do you want to try again?\n\nEnter any letter to continue or \"n\" to exit the program\n";
- cin >> ans;
- if (ans == "n")
- {
- break;
- }
- }
- }
- while (true)
- {
- cout << "5. Ceteris paribus means: \n";
- cout << "\ta. in sets of two\n";
- cout << "\tb. constant opportunity cost\n";
- cout << "\tc. other things being equal\n";
- cout << "\td. buyer beware\n";
- cout << "\te. there is no reason to argue about people's tastes\n";
- cout << "Answer: ";
- cin >> choice;
- if (choice == "c")
- {
- correct++;
- cout << "Correct: Other things being equal\n\n\n";
- break;
- }
- else
- if ((choice >= "a" && choice <= "b") || (choice >= "d" && choice <= "e"))
- {
- wrong++;
- cout << "\aWrong!!!\n\n\n";
- break;
- }
- else
- if ((choice >= "f" || choice <= "z"))
- {
- cout << "Wrong input! Your input is out of range!\n\n";
- cout << "Do you want to try again?\n\nEnter any letter to continue or \"n\" to exit the program\n";
- cin >> ans;
- if (ans == "n")
- {
- break;
- }
- }
- }
- while (true)
- {
- cout << "6. Which of the following is a true normative statement?\n";
- cout << "\ta. we should strive to push the PPF outward\n";
- cout << "\tb. points on the production possiblities frontier (PPF) are efficient\n";
- cout << "Answer: ";
- cin >> choice;
- if (choice == "a")
- {
- correct++;
- cout << "Correct: We should strive to push the PPF outward\n\n\n";
- break;
- }
- else
- if (choice >= "b" && choice <= "e")
- {
- wrong++;
- cout << "\aWrong!!!\n\n\n";
- break;
- }
- else
- if ((choice >= "f" || choice <= "z"))
- {
- cout << "Wrong input! Your input is out of range!\n\n";
- cout << "Do you want to try again?\n\nEnter any letter to continue or \"n\" to exit the program\n";
- cin >> ans;
- if (ans == "n")
- {
- break;
- }
- }
- }
- while (true)
- {
- cout << "7. Which of the following is a positive statement?\n";
- cout << "\ta. an economist should test every theory at least twice\n";
- cout << "\tb. increases in the minimum wage cause unemployment\n";
- cout << "\tc. we ought to deregulate the mortgage market\n";
- cout << "\td. the government must provide unlimited health care to citizens\n";
- cout << "\te. we should forgo some current consumption for a better future\n";
- cout << "Answer: ";
- cin >> choice;
- if (choice == "b")
- {
- correct++;
- cout << "Correct: increases in the minimum wage cause unemployment\n\n\n";
- break;
- }
- else
- if ((choice >= "a" && choice <= "a") || (choice >= "c" && choice <= "e"))
- {
- wrong++;
- cout << "\aWrong!!!\n\n\n";
- break;
- }
- else
- if ((choice >= "f" || choice <= "z"))
- {
- cout << "Wrong input! Your input is out of range!\n\n";
- cout << "Do you want to try again?\n\nEnter any letter to continue or \"n\" to exit the program\n";
- cin >> ans;
- if (ans == "n")
- {
- break;
- }
- }
- }
- while (true)
- {
- cout << "8. The world is the laboratory of the economist\n";
- cout << "\ta. true\n";
- cout << "\tb. false\n";
- cout << "Answer: ";
- cin >> choice;
- if (choice == "a")
- {
- correct++;
- cout << "Correct: The world is the laboratory of the economist\n\n\n";
- break;
- }
- else
- if (choice >= "b" && choice <= "e")
- {
- wrong++;
- cout << "\aWrong!!!\n\n\n";
- break;
- }
- else
- if ((choice >= "f" || choice <= "z"))
- {
- cout << "Wrong input! Your input is out of range!\n\n";
- cout << "Do you want to try again?\n\nEnter any letter to continue or \"n\" to exit the program\n";
- cin >> ans;
- if (ans == "n")
- {
- break;
- }
- }
- }
- while (true)
- {
- cout << "9. A positive statement: \n";
- cout << "\ta. is a claim that can be tested\n";
- cout << "\tb. is a statement about what ought to be\n";
- cout << "\tc. is a declaration of opinion\n";
- cout << "\td. is a claim that cannot be tested\n";
- cout << "\te. cannot be evaluated using the scientific method\n";
- cout << "Answer: ";
- cin >> choice;
- if (choice == "a")
- {
- correct++;
- cout << "Correct: Is a claim that can be tested\n\n\n";
- break;
- }
- else
- if (choice >= "b" && choice <= "e")
- {
- wrong++;
- cout << "\aWrong!!!\n\n\n";
- break;
- }
- else
- if ((choice >= "f" || choice <= "z"))
- {
- cout << "Wrong input! Your input is out of range!\n\n";
- cout << "Do you want to try again?\n\nEnter any letter to continue or \"n\" to exit the program\n";
- cin >> ans;
- if (ans == "n")
- {
- break;
- }
- }
- }
- while (true)
- {
- cout << "10. Because of scarcity individuals/society must always make a choice\n";
- cout << "\ta. True\n";
- cout << "\tb. False\n";
- cout << "Answer: ";
- cin >> choice;
- if (choice == "a")
- {
- correct++;
- cout << "Correct: True\n\n\n";
- break;
- }
- else
- if (choice <= "b" && choice <= "e")
- {
- wrong++;
- cout << "\aWrong!!!\n\n\n";
- break;
- }
- else
- if ((choice >= "f" || choice <= "z"))
- {
- cout << "Wrong input! Your input is out of range!\n\n";
- cout << "Do you want to try again?\n\nEnter any letter to continue or \"n\" to exit the program\n";
- cin >> ans;
- if (ans == "n")
- {
- break;
- }
- }
- }
- while (true)
- {
- cout << "11. A good is ______ if it takes even time, energy, or money to acquire\n";
- cout << "\ta. abundant\n";
- cout << "\tb. in shortage\n";
- cout << "\tc. cheap\n";
- cout << "\td. scarce\n";
- cout << "\te. virtually free\n";
- cout << "Answer: ";
- cin >> choice;
- if (choice == "d")
- {
- correct++;
- cout << "Correct: Scarce\n\n\n";
- break;
- }
- else
- if ((choice >= "a" && choice <= "c") || (choice >= "e" && choice <= "e"))
- {
- wrong++;
- cout << "\aWrong!!!\n\n\n";
- break;
- }
- else
- if ((choice >= "f" || choice <= "z"))
- {
- cout << "Wrong input! Your input is out of range!\n\n";
- cout << "Do you want to try again?\n\nEnter any letter to continue or \"n\" to exit the program\n";
- cin >> ans;
- if (ans == "n")
- {
- break;
- }
- }
- }
- while (true)
- {
- cout << "12. Increase in government involvement failed Thomas Malthus's prediction\n";
- cout << "\ta. True\n";
- cout << "\tb. False\n";
- cout << "Answer: ";
- cin >> choice;
- if (choice == "b")
- {
- correct++;
- cout << "Correct: False\n\n\n";
- break;
- }
- else
- if ((choice >= "a" && choice <= "a") || (choice >= "c" && choice <= "e"))
- {
- wrong++;
- cout << "\aWrong!!!\n\n\n";
- break;
- }
- else
- if ((choice >= "f" || choice <= "z"))
- {
- cout << "Wrong input! Your input is out of range!\n\n";
- cout << "Do you want to try again?\n\nEnter any letter to continue or \"n\" to exit the program\n";
- cin >> ans;
- if (ans == "n")
- {
- break;
- }
- }
- }
- while (true)
- {
- cout << "13. Why do economists use models?\n";
- cout << "\ta. models are used to add complexity to a simple world\n";
- cout << "\tb. models allow us to study a simplified version of a complex world\n";
- cout << "\tc. models allow us to control exogenous factors\n";
- cout << "\td. models make the world harder to understand\n";
- cout << "\te. models allow us to examine more factors even beyond our world\n";
- cout << "Answer: ";
- cin >> choice;
- if (choice == "b")
- {
- correct++;
- cout << "Correct: models are used to add complexity to a simple world\n\n\n";
- break;
- }
- else
- if ((choice >= "a" && choice <= "a") || (choice >= "c" && choice <= "e"))
- {
- wrong++;
- cout << "\aWrong!!!\n\n\n";
- break;
- }
- else
- if ((choice >= "f" || choice <= "z"))
- {
- cout << "Wrong input! Your input is out of range!\n\n";
- cout << "Do you want to try again?\n\nEnter any letter to continue or \"n\" to exit the program\n";
- cin >> ans;
- if (ans == "n")
- {
- break;
- }
- }
- }
- while (true)
- {
- cout << "14. Trade-off and opportunity cost are one and the same thing\n";
- cout << "\ta. True\n";
- cout << "\tb. False\n";
- cout << "Answer: ";
- cin >> choice;
- if (choice == "b")
- {
- correct++;
- cout << "Correct: False\n\n\n";
- break;
- }
- else
- if ((choice >= "a" && choice <= "a") || (choice >= "c" && choice <= "e"))
- {
- wrong++;
- cout << "\aWrong!!!\n\n\n";
- break;
- }
- else
- if ((choice >= "f" || choice <= "z"))
- {
- cout << "Wrong input! Your input is out of range!\n\n";
- cout << "Do you want to try again?\n\nEnter any letter to continue or \"n\" to exit the program\n";
- cin >> ans;
- if (ans == "n")
- {
- break;
- }
- }
- }
- while (true)
- {
- cout << "15. The basic goal of economics is: \n";
- cout << "\ta. controlling the effects of government actions\n";
- cout << "\tb. determine how to distribute all that is produced in an economy\n";
- cout << "\tc. addressing scarcity problem created by population's desire\n";
- cout << "\td. matching limited resources to people's limited wants and needs\n";
- cout << "\te. controlling tastes and wishes to produce resources that meets wants\n";
- cout << "Answer: ";
- cin >> choice;
- if (choice == "c")
- {
- correct++;
- cout << "Correct: Addressing scarcity problem created by population's desire\n\n\n";
- break;
- }
- else
- if ((choice >= "a" && choice <= "b") || (choice >= "d" && choice <= "e"))
- {
- wrong++;
- cout << "\aWrong!!!\n\n\n";
- break;
- }
- else
- if ((choice >= "f" || choice <= "z"))
- {
- cout << "Wrong input! Your input is out of range!\n\n";
- cout << "Do you want to try again?\n\nEnter any letter to continue or \"n\" to exit the program\n";
- cin >> ans;
- if (ans == "n")
- {
- break;
- }
- }
- }
- cout << "You answered " << correct << " out of 15 questions correctly\n";
- cout << "You got " << wrong << " answers wrong\n";
- if (correct < 7)
- {
- cout << "Your grade is poor\n\n";
- }
- else
- if (correct >= 7 && correct <= 10)
- {
- cout << "Your grade is fair\n\n";
- }
- else
- {
- cout << "Your grade is good\n\n";
- }
- count++;
- cout << "Do you want to take the test again? ";
- cin >> ans;
- if (ans == "no" || ans == "n")
- {
- break;
- }
- else
- {
- correct = 0;
- wrong = 0;
- }
- }
- cout << "You took the test " << count << " times\n";
- system("PAUSE");
- }