SHOW:
|
|
- or go back to the newest paste.
1 | //Eric Johnson | |
2 | //Simple Calculator | |
3 | //03-27-12 | |
4 | #include <iostream> | |
5 | #include <math> | |
6 | #include "calc_func.hpp" | |
7 | #include "clear.hpp" | |
8 | ||
9 | using namespace std; | |
10 | int main() | |
11 | { | |
12 | char operation; | |
13 | double a, b, answer; | |
14 | cout << "Please input the first operand: "; | |
15 | cin >> a; | |
16 | clear(); | |
17 | cout << "Please input the second operand: "; | |
18 | cin >> b; | |
19 | - | cout << "Please input the operation you wish to perform: " |
19 | + | |
20 | - | cin >> operation |
20 | + | int lookup[]= |
21 | - | switch (operation) |
21 | + | { |
22 | (operation = "a"),(operation = "m"),(operation = "d"),(operation = "s"), | |
23 | (operation = "p"),(operation = "r"), | |
24 | - | add(); |
24 | + | }; |
25 | cout << "Please choose the operation you would like to perform: " << endl; | |
26 | cin >> operation ; | |
27 | - | multiply(); |
27 | + | switch (lookup) |
28 | { | |
29 | case (a): | |
30 | - | divide(); |
30 | + | add(a, b, answer); |
31 | break; | |
32 | case (m): | |
33 | - | subtract(); |
33 | + | multiply(a, b, answer); |
34 | break; | |
35 | case (d): | |
36 | - | AtoB(); |
36 | + | divide(a, b, answer); |
37 | break; | |
38 | case (s): | |
39 | - | BtoA(); |
39 | + | subtract(a, b, answer); |
40 | break; | |
41 | case (p): | |
42 | AtoB(a, b, answer); | |
43 | break; | |
44 | case (r): | |
45 | BtoA(a, b, answer); | |
46 | break; | |
47 | } | |
48 | cout << "\nThese are you operands: " << a << "&: " << b << endl; | |
49 | cout << "This is the answer to your problems: " << answer << endl; | |
50 | } |