View difference between Paste ID: ckN6fthm and h1GXvA7W
SHOW: | | - or go back to the newest paste.
1
#include <iostream>
2
#include <string>
3
4
using namespace std;
5
6
int main()
7
{
8
9
    string start = "";
10
11
    double num1;
12
    double num2;
13
    double result;
14
    int a;
15
16
    while (a != 5)
17
    {
18-
        cout << "This calculator was made by Evan Malz\n" << endl;
18+
        cout << "Copyright © 2012 Evan Malz, All rights reserved\n" << endl;
19
        cout << "Type 'Go' to start the calculator, 'Help' for i"
20
             << "nstructions, or 'Exit' to quit\n" << endl;
21
        cin >> start;
22
        // Asks for inputs 'go' or 'help'
23
        cout << "\n" << endl;
24
25
        if (start == "exit")
26
        {
27
            cout << "Press Enter to exit. \n";
28
            cin.ignore();
29
            cin.get();
30
            return 0;
31
            // Exits program if user imputs 'exit'
32
        }
33
34
        if (start == "help")
35
        {
36
            cout << "For steps 1 and 2, you will be asked to enter 2 nu"
37
                 << "mbers.\nFor step 3, you will choose an operation, "
38
                 << "for example,\nfor multiplication you would type '1"
39
                 << "'. You will return\nto Step 1 after receiving the "
40-
                 << "answer to your calculation,\nand in order to exit,"
40+
                 << "answer to your calculation" << endl;
41-
                 << " you have to type '5' when you are\nat Step 3.\n"
41+
42-
                 << endl;
42+
43
        if (start == "go")
44
        {
45
            // Below is what will happen if the user imputs 'go'
46
47
            cout << "Step 1" << endl;
48
            cout << "Enter first integer: \n" << endl;
49
            // Asks for first number
50
51
            cin >> num1;
52
            // Defines 'num1' as the number imput above
53
54
            cout << "\n" << endl;
55
56
            cout << "Step 2" << endl;
57
            cout << "Enter second integer: \n" << endl;
58
            // Asks for second number
59
60
            cin >> num2;
61
            // Defines 'num2' as the number imput above
62
63
            cout << "\n" << endl;
64
65
            cout << "Step 3" << endl;
66
            cout << "Choose an operation below (Type only the number)"
67
                 << "\n\n1 = Multiply (x) ---- 5 = Exit calculator\n"
68
                 << "2 = Divide   (/)           \n3 = Add      (+)\n4 = "
69
                 << "Subtract (-)\n" << endl;
70
            // Asks for number of operation
71
72
            cin >> a;
73
            // Defines 'a' as the number imput above
74
75
            cout << "\n" << endl;
76
        }
77
78
        switch(a)
79
        {
80
        case 1:
81
            result = num1 * num2;
82
            cout << num1 << " x " << num2 << " = " << result << "\n"
83
                 << "";
84
            cout << "\n" << endl;
85
            cout << "When you're finished, type '5' at Step 3 to ex"
86
                 << "it\n" << endl;
87
            break;
88
            // This case is used if user types '1'. Selects multiplicat-
89
            // ion
90
91
        case 2:
92
            result = num1 / num2;
93
            cout << num1 << " / " << num2 << " = " << result << "\n"
94
                 << "";
95
            cout << "\n" << endl;
96
            cout << "When you're finished, type '5' at Step 3 to ex"
97
                 << "it\n" << endl;
98
            break;
99
            // This case is used if user types '2'. Selects division
100
101
        case 3:
102
            result = num1 + num2;
103
            cout << num1 << " + " << num2 << " = " << result << "\n"
104
                 << "";
105
            cout << "\n" << endl;
106
            cout << "When you're finished, type '5' at Step 3 to ex"
107
                 << "it\n" << endl;
108
            break;
109
            // This case is used if user types '3'. Selects addition
110
111
        case 4:
112
            result = num1 - num2;
113
            cout << num1 << " - " << num2 << " = " << result << "\n"
114
                 << "";
115
            cout << "\n" << endl;
116
            cout << "When you're finished, type '5' at Step 3 to ex"
117
                 << "it\n" << endl;
118
            break;
119
            // This case is used if user types '4'. Selects subtraction
120
121
        case 5:
122
            cout << "Thanks for using my calculator! Press Enter to"
123
                 << "exit" << endl;
124
            // This case is used if user types '5'. Exits program
125
            cout << "Press enter to exit. \n";
126
            cin.ignore();
127
            cin.get();
128
            return 0;
129
        }
130
    }
131
}