Help on the final parts of my calculator

Hello all!

You probably remember me from the last week or so. I have another question for those of whom might be interested.

I've finished my calculator for the most part, and now I'm having trouble with two things. The first is that every time I select the number seven to exit the program, and I put in the character y or n, the program seems to go absolutely haywire.

Can anyone help me with this? There's a nested if statement that turns the program off if the answer is y.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
  #include <iostream>
#include <cmath>
#include <cstdlib>

using namespace std;

int main()
{
    int option;
    int y;
    int n;
    double number1;
    double number2;
    double pi = 3.14;
    double area1;
    double area;

    cout << "Greetings. I am The Sage, what game shall we play today?" << endl;

    for (;;)
    {
        cout << endl << "Choose your path, choose your game. \n"
             << endl
             << "1 Calculate the Area of an Ellipse \n"
             << "2 Calculate the Area of a Sector \n"
             << "3 Calculate the Area of a Triangle \n"
             << "4 Calculate the Area of a Rhombus \n"
             << "5 Calculate the Area of a Pentagon \n"
             << endl
             << "You may also read more about the Sage. \n"
             << "6 About the Sage \n"
             << "7 Leave \n"
             << endl
             << "What will you play? \n"
             << endl;

        cin >> option;

        switch (option)
        {
        case 1: cout << endl << "I am going to calculate the area of an Ellipse. \n";
                cout << "Enter your first number. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the second number. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = pi * number1 * number2;
                cout << "The area of ellipse is " << area;

                break;

        case 2: cout << endl << "I am going to calculate the area of an Sector. \n";
                cout << "Enter your first radius. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the angle. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = pi * pow(number1, 2) * number2 / 360;
                cout << "The area of sector is " << area;

                break;

        case 3: cout << endl << "I am going to calculate the area of an Triangle. \n";
                cout << "Enter your first base of the triangle. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the height. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = number1 * number2 / 2;
                cout << "The area of triangle is " << area;

                break;

        case 4: cout << endl << "I am going to calculate the area of a rhombus. \n";
                cout << "Enter your length. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter width. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = number1 * number2;
                cout << "The area of rhombus is " << area;

                break;

        case 5:

                cout << endl << "I am going to calculate the area of a Pentagon. \n";
                cout << "We will split the polygon into five pieces. \n";
                cout << "Enter your first base of the triangle. \n";
                cin >> number1;
            while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the height. \n";
                cin >> number2;
            while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area1 = number1 * number2 / 2;
                cout << "The area of triangle is " << area1 << endl;
                cout << "Now, we shall multiply by Five. \n";
                area = area1 * 5;
                cout << "Your area is, " << area << endl << endl;


                break;

        case 6: cout << endl << "I...am the sage. \n";
                cout << "I was once a mere student of Computer science \n";
                cout << "but after a computer accident, I had to recuperate. \n";
                cout << "They could rebuild me. They had the technology. \n";
                cout << "They had the capabilty to make me better... \n";
                cout << "Faster.... \n";
                cout << "Stronger. \n";

                break;

        case 7: cout << endl << "Are you ready to leave, my friend? So soon? \n";
                cout << "y or n ? \n";
                cin >> option;
                if(option == n)
                {
                    break;
                    if(option == y)
                    {
                        cout << "We will meet again, I am sure.";

                    }

                }

        }
    }

    return 0;
    system(pause);
}
Shot in the dark, you declare option as an int but then on line 170 stuff a char in it via cin>> try using an actual char instead of option.

EDIT: also, putting any code after return 0; is redundant.
The proper use of system () is system("use the quotes"); and using system for anything but little programs or homework (which I'm guessing this is) is a really bad idea.

EDIT EDIT: don't use nested ifs like that. Do this instead:
1
2
3
4
5
6
7
8
if(option == n)
{
      break;
}
if(option == y)
{
      cout << "We will meet again, I am sure.";
}
Last edited on
Dear Sargon,

Thanks for that info. I worked on the if statements, but I decided to change them to else since it would be a bit easier.

I've now gotten this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#include <iostream>
#include <cmath>
#include <cstdlib>

using namespace std;

int main()
{
    int option;
    int y;
    int n;
    double number1;
    double number2;
    double pi = 3.14;
    double area1;
    double area;

    cout << "Greetings. I am The Sage, what game shall we play today?" << endl;

    for (;;)
    {
        cout << endl << "Choose your path, choose your game. \n"
             << endl
             << "1 Calculate the Area of an Ellipse \n"
             << "2 Calculate the Area of a Sector \n"
             << "3 Calculate the Area of a Triangle \n"
             << "4 Calculate the Area of a Rhombus \n"
             << "5 Calculate the Area of a Pentagon \n"
             << endl
             << "You may also read more about the Sage. \n"
             << "6 About the Sage \n"
             << "7 Leave \n"
             << endl
             << "What will you play? \n"
             << endl;

        cin >> option;

        switch (option)
        {
        case 1: cout << endl << "I am going to calculate the area of an Ellipse. \n";
                cout << "Enter your first number. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the second number. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = pi * number1 * number2;
                cout << "The area of ellipse is " << area;

                break;

        case 2: cout << endl << "I am going to calculate the area of an Sector. \n";
                cout << "Enter your first radius. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the angle. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = pi * pow(number1, 2) * number2 / 360;
                cout << "The area of sector is " << area;

                break;

        case 3: cout << endl << "I am going to calculate the area of an Triangle. \n";
                cout << "Enter your first base of the triangle. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the height. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = number1 * number2 / 2;
                cout << "The area of triangle is " << area;

                break;

        case 4: cout << endl << "I am going to calculate the area of a rhombus. \n";
                cout << "Enter your length. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter width. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = number1 * number2;
                cout << "The area of rhombus is " << area;

                break;

        case 5:

                cout << endl << "I am going to calculate the area of a Pentagon. \n";
                cout << "We will split the polygon into five pieces. \n";
                cout << "Enter your first base of the triangle. \n";
                cin >> number1;
            while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the height. \n";
                cin >> number2;
            while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area1 = number1 * number2 / 2;
                cout << "The area of triangle is " << area1 << endl;
                cout << "Now, we shall multiply by Five. \n";
                area = area1 * 5;
                cout << "Your area is, " << area << endl << endl;


                break;

        case 6: cout << endl << "I...am the sage. \n";
                cout << "I was once a mere student of Computer science \n";
                cout << "but after a computer accident, I had to recuperate. \n";
                cout << "They could rebuild me. They had the technology. \n";
                cout << "They had the capabilty to make me better... \n";
                cout << "Faster.... \n";
                cout << "Stronger. \n";

                break;

        case 7: cout << endl << "Are you ready to leave, my friend? So soon? \n";
                cout << "y or n ? \n";
                cin >> option;
               if(option == y)
{
      cout << "We will meet again, I am sure.";
}
else{
    break;
}

return 0;

}


And It says for the error, this:

expected "}" at end of input. What might I be doing wrong at line 181?
Hi I'm a complete noob to c++. but I believe the error you get in the end is because the "}" you placed on line 181 is connected to the one placed on line 21, instead of line 8.

Try changing that :) If that doesn't help, I'm sorry.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#include <iostream>
#include <cmath>
#include <cstdlib>

using namespace std;

int main()
{
    int option;
    int y;
    int n;
    double number1;
    double number2;
    double pi = 3.14;
    double area1;
    double area;

    cout << "Greetings. I am The Sage, what game shall we play today?" << endl;

    for (;;)
    {
        cout << endl << "Choose your path, choose your game. \n"
             << endl
             << "1 Calculate the Area of an Ellipse \n"
             << "2 Calculate the Area of a Sector \n"
             << "3 Calculate the Area of a Triangle \n"
             << "4 Calculate the Area of a Rhombus \n"
             << "5 Calculate the Area of a Pentagon \n"
             << endl
             << "You may also read more about the Sage. \n"
             << "6 About the Sage \n"
             << "7 Leave \n"
             << endl
             << "What will you play? \n"
             << endl;

        cin >> option;

        switch (option)
        {
        case 1: cout << endl << "I am going to calculate the area of an Ellipse. \n";
                cout << "Enter your first number. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the second number. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = pi * number1 * number2;
                cout << "The area of ellipse is " << area;

                break;

        case 2: cout << endl << "I am going to calculate the area of an Sector. \n";
                cout << "Enter your first radius. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the angle. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = pi * pow(number1, 2) * number2 / 360;
                cout << "The area of sector is " << area;

                break;

        case 3: cout << endl << "I am going to calculate the area of an Triangle. \n";
                cout << "Enter your first base of the triangle. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the height. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = number1 * number2 / 2;
                cout << "The area of triangle is " << area;

                break;

        case 4: cout << endl << "I am going to calculate the area of a rhombus. \n";
                cout << "Enter your length. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter width. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = number1 * number2;
                cout << "The area of rhombus is " << area;

                break;

        case 5:

                cout << endl << "I am going to calculate the area of a Pentagon. \n";
                cout << "We will split the polygon into five pieces. \n";
                cout << "Enter your first base of the triangle. \n";
                cin >> number1;
            while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the height. \n";
                cin >> number2;
            while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area1 = number1 * number2 / 2;
                cout << "The area of triangle is " << area1 << endl;
                cout << "Now, we shall multiply by Five. \n";
                area = area1 * 5;
                cout << "Your area is, " << area << endl << endl;


                break;

        case 6: cout << endl << "I...am the sage. \n";
                cout << "I was once a mere student of Computer science \n";
                cout << "but after a computer accident, I had to recuperate. \n";
                cout << "They could rebuild me. They had the technology. \n";
                cout << "They had the capabilty to make me better... \n";
                cout << "Faster.... \n";
                cout << "Stronger. \n";

                break;

        case 7: cout << endl << "Are you ready to leave, my friend? So soon? \n";
                cout << "y or n ? \n";
                cin >> option;
               if(option == y)
{
      cout << "We will meet again, I am sure.";
}
else{
    break;
}
        }//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<add this

        }//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<and this ;)
return 0;
}
Last edited on
I performed both of those edits and still it has the same response.

Edit. Now I've done the edits above, it works, but now I'm trying to get it to return to the first menu.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#include <iostream>
#include <cmath>
#include <cstdlib>

using namespace std;

int main()
{
    int option;
    int y;
    int n;
    double number1;
    double number2;
    double pi = 3.14;
    double area1;
    double area;

    cout << "Greetings. I am The Sage, what game shall we play today?" << endl;

    for (;;)
    {
        cout << endl << "Choose your path, choose your game. \n"
             << endl
             << "1 Calculate the Area of an Ellipse \n"
             << "2 Calculate the Area of a Sector \n"
             << "3 Calculate the Area of a Triangle \n"
             << "4 Calculate the Area of a Rhombus \n"
             << "5 Calculate the Area of a Pentagon \n"
             << endl
             << "You may also read more about the Sage. \n"
             << "6 About the Sage \n"
             << "7 Leave \n"
             << endl
             << "What will you play? \n"
             << endl;

        cin >> option;

        switch (option)
        {
        case 1: cout << endl << "I am going to calculate the area of an Ellipse. \n";
                cout << "Enter your first number. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the second number. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = pi * number1 * number2;
                cout << "The area of ellipse is " << area;

                break;

        case 2: cout << endl << "I am going to calculate the area of an Sector. \n";
                cout << "Enter your first radius. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the angle. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = pi * pow(number1, 2) * number2 / 360;
                cout << "The area of sector is " << area;

                break;

        case 3: cout << endl << "I am going to calculate the area of an Triangle. \n";
                cout << "Enter your first base of the triangle. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the height. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = number1 * number2 / 2;
                cout << "The area of triangle is " << area;

                break;

        case 4: cout << endl << "I am going to calculate the area of a rhombus. \n";
                cout << "Enter your length. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter width. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = number1 * number2;
                cout << "The area of rhombus is " << area;

                break;

        case 5:

                cout << endl << "I am going to calculate the area of a Pentagon. \n";
                cout << "We will split the polygon into five pieces. \n";
                cout << "Enter your first base of the triangle. \n";
                cin >> number1;
            while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the height. \n";
                cin >> number2;
            while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area1 = number1 * number2 / 2;
                cout << "The area of triangle is " << area1 << endl;
                cout << "Now, we shall multiply by Five. \n";
                area = area1 * 5;
                cout << "Your area is, " << area << endl << endl;


                break;

        case 6: cout << endl << "I...am the sage. \n";
                cout << "I was once a mere student of Computer science \n";
                cout << "but after a computer accident, I had to recuperate. \n";
                cout << "They could rebuild me. They had the technology. \n";
                cout << "They had the capabilty to make me better... \n";
                cout << "Faster.... \n";
                cout << "Stronger. \n";

                break;

        case 7: cout << endl << "Are you ready to leave, my friend? So soon? \n";
                cout << "y or n ? \n";
                cin >> option;
               if(option == y)
{
      cout << "We will meet again, I am sure.";
}
else{
             cout << endl << "What would you like to do? \n";
             cin >> option;
}
        }
return 0;
        }
}


the error that comes up is that the file cannot be opened, and permission has been denied.
Ok ok, my apologies, I made a mistake in my first post. Here's what's wrong in order.

1st: option is declared as an int on line 9. This is a good thing since you use it to input numbers for most of the program. However, "y" and "n" are of the char (character) type and therefore cannot be stored in the variable option. Therefore, you must create a new variable (called whatever you want) and make it a type char like this: char nameofvariablehere;

2nd: on line 170 you then put cin>>nameofvariablehere instead of option. Because it is a char you must also modify you if statement like so: if (nameofvariablehere=='y')

3rd: to loop back the menu replace line 177 with break; Also, to close the program is they input "y", add return 0; after line 173 (but before the "}" symbol)

Finally: Your error, when is it happening? When you compile? What file can't be opened?
So, after making your suggested corrections, I have this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#include <iostream>
#include <cmath>
#include <cstdlib>

using namespace std;

int main()
{
    int option;
    char confirm;
    int y;
    double number1;
    double number2;
    double pi = 3.14;
    double area1;
    double area;

    cout << "Greetings. I am The Sage, what game shall we play today?" << endl;

    for (;;)
    {
        cout << endl << "Choose your path, choose your game. \n"
             << endl
             << "1 Calculate the Area of an Ellipse \n"
             << "2 Calculate the Area of a Sector \n"
             << "3 Calculate the Area of a Triangle \n"
             << "4 Calculate the Area of a Rhombus \n"
             << "5 Calculate the Area of a Pentagon \n"
             << endl
             << "You may also read more about the Sage. \n"
             << "6 About the Sage \n"
             << "7 Leave \n"
             << endl
             << "What will you play? \n"
             << endl;

        cin >> option;

        switch (option)
        {
        case 1: cout << endl << "I am going to calculate the area of an Ellipse. \n";
                cout << "Enter your first number. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the second number. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = pi * number1 * number2;
                cout << "The area of ellipse is " << area;

                break;

        case 2: cout << endl << "I am going to calculate the area of an Sector. \n";
                cout << "Enter your first radius. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the angle. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = pi * pow(number1, 2) * number2 / 360;
                cout << "The area of sector is " << area;

                break;

        case 3: cout << endl << "I am going to calculate the area of an Triangle. \n";
                cout << "Enter your first base of the triangle. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the height. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = number1 * number2 / 2;
                cout << "The area of triangle is " << area;

                break;

        case 4: cout << endl << "I am going to calculate the area of a rhombus. \n";
                cout << "Enter your length. \n";
                cin >> number1;
                while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter width. \n";
                cin >> number2;
                while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area = number1 * number2;
                cout << "The area of rhombus is " << area;

                break;

        case 5:

                cout << endl << "I am going to calculate the area of a Pentagon. \n";
                cout << "We will split the polygon into five pieces. \n";
                cout << "Enter your first base of the triangle. \n";
                cin >> number1;
            while (number1==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number1;
                }
                cout << "Now, my friend, enter the height. \n";
                cin >> number2;
            while (number2==0)
                 {
                cout << "You CANNOT use a zero." << endl;
                cout << "Enter another number!....My friend." << endl;
                cin >> number2;
                }
                area1 = number1 * number2 / 2;
                cout << "The area of triangle is " << area1 << endl;
                cout << "Now, we shall multiply by Five. \n";
                area = area1 * 5;
                cout << "Your area is, " << area << endl << endl;


                break;

        case 6: cout << endl << "I...am the sage. \n";
                cout << "I was once a mere student of Computer science \n";
                cout << "but after a computer accident, I had to recuperate. \n";
                cout << "They could rebuild me. They had the technology. \n";
                cout << "They had the capabilty to make me better... \n";
                cout << "Faster.... \n";
                cout << "Stronger. \n";

                break;

        case 7: cout << endl << "Are you ready to leave, my friend? So soon? \n";
                cout << "y or n ? \n";
                cin >> confirm;
               if(confirm == y)
{
      cout << "We will meet again, I am sure.";
      return 0;
}
else{
             cout << endl << "What would you like to do? \n";
             break;
}
        }

        }
}


Should it look like that?

Also, the only error left is the error of the file not being able to be opened , and that is after I build the program.
line 171: if (confirm == 'y') remember the quotes.

Aside from that everything looks fine :D

So... you build it, and then when it tries to run it says it's unable to open the .exe? Erm... check with your OS (I'm guessing you're using windows?). Check your account privileges. If you're in a class ask your teacher.
Ah, well this is my final. LOL.

I thank you all for helping me. I'm going to turn this into my teacher with the IPO CHart and Flowchart and I am going to get to bed.

Over winter break, I am going to study this at my leisure.
Topic archived. No new replies allowed.