Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. /*
  2. Author: Anthony Rodriguez, DeAndre Rogers
  3. Date: Nov 6 19
  4. Class: ITSE 1302 - Intro to Computer Programming
  5. Instructor: Prof Welch
  6. The Math Tutor 2
  7. */
  8.  
  9.  
  10. #include <iostream> //cin, cout
  11. #include <iomanip> // setw(), fixed, showpoint, setprecision
  12. #include <string> // get string
  13. #include <cstdlib> // rand()
  14. #include <ctime> // get rand seed
  15. using namespace std;
  16.  
  17. //function prototypes
  18. int displayMenu();
  19. void add(double numA,double numB,double& total);
  20. void sub(double numA,double numB,double& total);
  21. void mult(double numA,double numB, double& total);
  22. void div(double numA,double numB, double& total);
  23. int compliment(int compA, int compB, int compC, int compD);
  24. int encourage(int encorA, int encorB, int encorC, int encorD);
  25.  
  26.  
  27.  
  28. int main()
  29. {
  30. int choice;
  31. int numA;
  32. int numB;
  33. int answer;
  34. int total;
  35. int seed;
  36.  
  37.  
  38. do
  39. {
  40. //Seed the random number generator
  41. seed = time(0);
  42.  
  43.  
  44. srand(seed);
  45. numA = 1 + rand() % 12;
  46. numB = 1 + rand() % 12;
  47.  
  48. cout << "----------------"<< endl;
  49. cout << " Math Tutor Menu \n";
  50. cout << "----------------"<< endl;
  51. cout << "1. Addition" << endl;
  52. cout << "2. Subtraction " << endl;
  53. cout << "3. Multiplication" << endl;
  54. cout << "4. Division " << endl;
  55. cout << "5. Quit the program " <<endl << endl;
  56. cin >> choice;
  57.  
  58. if (choice >= 1 && choice <= 5)
  59. {
  60.  
  61. cout << "Enter the total to the following problem:\n";
  62. cout << " " << numA << endl;
  63.  
  64. switch (choice)
  65. {
  66. case 1: void add();
  67. break;
  68. //case 2: total = num_A - num_B;
  69. //cout << " - ";
  70. //break;
  71. //case 3: total = num_A * num_B;
  72. //cout << " * ";
  73. //break;
  74. //case 4: total = num_A / num_B;
  75. //cout << " / ";
  76. }
  77.  
  78.  
  79. /*cout << num_B << endl;
  80. cout << " ------\n ";
  81. cin >> Input;*/
  82.  
  83. if (answer == total)
  84. cout << answer;
  85. else
  86. {
  87. cout << "\nWrong!\n";
  88. cout << "The correct answer is " << total << endl;
  89. }
  90. }
  91. if (choice < 1 || choice > 5)
  92. {
  93. cout << "Error 404: Please enter the number in range. (Between 1 & 5)\n";
  94. }
  95. if (choice == 5)
  96. cout << "Exiting! See ya around!\n\n";
  97.  
  98. } while (choice != 5);
  99.  
  100. cin.get();
  101. return 0;
  102.  
  103. }
  104.  
  105. //addition
  106. void add(){
  107. int numA = 1 + rand() % 12;
  108. int numB = 1 + rand() % 12;
  109. cout << " + ";
  110. total = numA + numB;
  111. cout << numB << endl;
  112. cout << " ------\n ";
  113. cin >> ans;
  114. }
  115. /*
  116. double addition(double numA,double numB){
  117.  
  118. double sum = 0;
  119. sum = numA + numB;
  120. return sum;
  121.  
  122. }
  123.  
  124. //subtraction
  125. void sub(double numA,double numB,double& numC){
  126. numA = (rand() % (maxNum - minNum + 1)) + minNum;
  127. numB = (rand() % (maxNum - minNum + 1)) + minNum;
  128. numC = numA - numB;
  129.  
  130. }
  131.  
  132. double subtraction(double numA,double numB){
  133.  
  134. double total = 0;
  135. total = numA - numB;
  136. return total;
  137.  
  138. }
  139. //multiplication
  140. void mult(double numA,double numB, double& numC){
  141. numA = (rand() % (maxNum - minNum + 1)) + minNum;
  142. numB = (rand() % (maxNum - minNum + 1)) + minNum;
  143. numC = numA * numB;
  144.  
  145. }
  146.  
  147. double multiplication(double numA,double numB){
  148.  
  149. double total = 0;
  150. total = numA * numB;
  151. return total;
  152.  
  153. }
  154. //division
  155. void div(double numA,double numB, double& numC){
  156.  
  157. numA = (rand() % (maxNum - minNum + 1)) + minNum;
  158. numB = (rand() % (maxNum - minNum + 1)) + minNum;
  159. numC = numA / numB;
  160.  
  161. }
  162.  
  163. double division(double numA,double numB){
  164.  
  165. double total = 0;
  166. total = numA / numB;
  167. return total;
  168.  
  169. }
  170.  
  171. //int compliment() {
  172. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement