Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. // Author: Mitchell Burnett
  2. // Summative Task: 1, 12, March, 2015.
  3. // Summative Task 2, 20, March, 2015.
  4.  
  5.  
  6. #include <iostream>
  7. #include <ctime>
  8. #include <cstdlib>
  9. using namespace std;
  10.  
  11. bool confirmUser(char input, char upper, char lower);
  12. int getMin(int year, int min);
  13.  
  14. int main(){
  15.  
  16. int value = 0;
  17. int oper = 0;
  18. int yearLevel;
  19. int numQuestions;
  20. // char mathsOperation;
  21. char confirm;
  22. double num1, num2;
  23. int count = 0;
  24. int min = 0;
  25. int max;
  26.  
  27.  
  28. cout << "Welcome to the Math Helper!\n";
  29. cout << "Use this application to test your abilities and knowledge of mathematics.\n";
  30. cout << "This program is intended for children from reception to year 7.\n";
  31. cout << "=============================================================================\n";
  32. system("pause"); // This command simulates "Press any key to continue. . ."
  33. do
  34. {
  35. 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 ";
  36. cin >> yearLevel; // User enters their year level.
  37. cin.ignore(100, '\n');
  38.  
  39. if (yearLevel >= 1 && yearLevel <= 7)
  40. {
  41. cout << "Your year level is " << yearLevel;
  42. cout << "\n";
  43. }
  44. else if (yearLevel == 0)
  45. {
  46. cout << "Your year level is Reception. ";
  47. cout << "\n";
  48. }
  49. else
  50. {
  51. yearLevel = 4;
  52. cout << "That was an invalid selection. Defaulting to Year 4 student.\n";
  53. cout << "Your year level is " << (yearLevel);
  54. cout << "\n"; // Any invalid input will set the yearlevel to 4.
  55. }
  56.  
  57. 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";
  58. cin >> numQuestions; // User enters the number of questions they want to attempt.
  59. cin.ignore(100, '\n');
  60.  
  61. if (numQuestions >= 0 && numQuestions <= 4)
  62. {
  63. cout << "You are a year " << yearLevel;
  64. cout << " and want to do ";
  65. cout << (numQuestions + 1) * 10;
  66. cout << " questions.";
  67. numQuestions = (numQuestions + 1) * 10; // Sets the input the the correct number of questions.
  68. }
  69. else
  70. {
  71. cout << "That was an invalid selection. Defaulting to 10 questions.\n";
  72. cout << "You are a year " << yearLevel;
  73. cout << " and you want to do ";
  74. cout << (numQuestions * 0) + 10;
  75. cout << "questions.";
  76. numQuestions = 10;
  77. }
  78.  
  79. cout << "\nIs this correct (Y/N)?"; // Comfirmation from the user of their inputs.
  80.  
  81. cin >> confirm;
  82.  
  83. } while (confirmUser(confirm, 'y', 'Y') == false);
  84.  
  85. cout << "Let's begin.\n";
  86.  
  87.  
  88. do
  89. {
  90. count++;
  91. int min = getMin;
  92. srand(unsigned(time(NULL)));
  93. cout << "What is " << num1 << " " << oper << num2;
  94.  
  95. } while (count <= numQuestions);
  96.  
  97. }
  98.  
  99.  
  100. bool confirmUser(char input, char upper, char lower)
  101.  
  102. {
  103. if (input == upper || input == lower)
  104. {
  105. return true;
  106. }
  107. else
  108. {
  109. return false;
  110. }
  111. }
  112.  
  113. int getMin(int year, int min)
  114. {
  115. if (year = 0 || 1 || 2 || 3 || 4)
  116. min = 0;
  117. else if (year = 5 || 6)
  118. min = -999;
  119. else if (year = 7)
  120. min = -9999;
  121. return min;
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement