Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Author: Mitchell Burnett
- // Summative Task: 1, 12, March, 2015.
- // Summative Task 2, 20, March, 2015.
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- bool confirmUser(char input, char upper, char lower);
- int getMin(int year, int min);
- int main(){
- int value = 0;
- int oper = 0;
- int yearLevel;
- int numQuestions;
- // char mathsOperation;
- char confirm;
- double num1, num2;
- int count = 0;
- int min = 0;
- int max;
- cout << "Welcome to the Math Helper!\n";
- cout << "Use this application to test your abilities and knowledge of mathematics.\n";
- cout << "This program is intended for children from reception to year 7.\n";
- cout << "=============================================================================\n";
- system("pause"); // This command simulates "Press any key to continue. . ."
- do
- {
- cout << "What is your year level?\n 0. Reception\n 1. Year 1\n 2. Year 2\n 3. Year 3\n 4. Year 4\n 5. Year 5\n 6. Year 6\n 7. Year 7\n ";
- cin >> yearLevel; // User enters their year level.
- cin.ignore(100, '\n');
- if (yearLevel >= 1 && yearLevel <= 7)
- {
- cout << "Your year level is " << yearLevel;
- cout << "\n";
- }
- else if (yearLevel == 0)
- {
- cout << "Your year level is Reception. ";
- cout << "\n";
- }
- else
- {
- yearLevel = 4;
- cout << "That was an invalid selection. Defaulting to Year 4 student.\n";
- cout << "Your year level is " << (yearLevel);
- cout << "\n"; // Any invalid input will set the yearlevel to 4.
- }
- cout << "How many questions did you want to attempt?\n 0. 10 Questions \n 1. 20 Questions\n 2. 30 Questions\n 3. 40 Questions\n 4. 50 Questions\n";
- cin >> numQuestions; // User enters the number of questions they want to attempt.
- cin.ignore(100, '\n');
- if (numQuestions >= 0 && numQuestions <= 4)
- {
- cout << "You are a year " << yearLevel;
- cout << " and want to do ";
- cout << (numQuestions + 1) * 10;
- cout << " questions.";
- numQuestions = (numQuestions + 1) * 10; // Sets the input the the correct number of questions.
- }
- else
- {
- cout << "That was an invalid selection. Defaulting to 10 questions.\n";
- cout << "You are a year " << yearLevel;
- cout << " and you want to do ";
- cout << (numQuestions * 0) + 10;
- cout << "questions.";
- numQuestions = 10;
- }
- cout << "\nIs this correct (Y/N)?"; // Comfirmation from the user of their inputs.
- cin >> confirm;
- } while (confirmUser(confirm, 'y', 'Y') == false);
- cout << "Let's begin.\n";
- do
- {
- count++;
- int min = getMin;
- srand(unsigned(time(NULL)));
- cout << "What is " << num1 << " " << oper << num2;
- } while (count <= numQuestions);
- }
- bool confirmUser(char input, char upper, char lower)
- {
- if (input == upper || input == lower)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- int getMin(int year, int min)
- {
- if (year = 0 || 1 || 2 || 3 || 4)
- min = 0;
- else if (year = 5 || 6)
- min = -999;
- else if (year = 7)
- min = -9999;
- return min;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement