Advertisement
EricJohnson

calc_main

Apr 4th, 2012
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Eric Johnson
  2. //Simple Calculator
  3. //Mr. Searing
  4. //SUPA Computer Engineering
  5. //04-04-12
  6. #include <iostream>
  7. #include <cmath>
  8. #include "calc_func.hpp"
  9. #include "clear.hpp"
  10. #include "menu.hpp"
  11. using namespace std;
  12. int main()
  13. {
  14. char operation, again='y';
  15. double a, b, answer;
  16. WHILE (again == 'y')
  17. {
  18. cout << "Please input the first operand: ";
  19. cin >> a;
  20. clear();
  21. cout << "Please input the second operand: ";
  22. cin >> b;
  23. clear();
  24. cout << "Please input the operation you would like to perform: ";
  25. cin >> operation;
  26. switch (operation)
  27. {
  28.     case ('a'):
  29.         //sets answer equal to the return from the call OF the function
  30.         answer=add(a,b);
  31.         break;
  32.     case ('m'):
  33.         answer=multiply(a,b);
  34.         break;
  35.     case ('d'):
  36.         answer=divide(a,b);
  37.         break;
  38.     case ('s'):
  39.         answer=subtract(a,b);
  40.         break;
  41.     case ('p'):
  42.         answer=AtoB(a,b);
  43.         break;
  44.     case ('R'):
  45.         answer=BtoA(a,b);
  46.         break;
  47. }
  48. cout << "\nThese are you operands: " << a << " &: " << b << endl;
  49. cout << "This is the answer to your problems: " << answer << endl;}
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement