c++ calculator

I'm trying to make a simple calculator with trig functions. I need to add a bool loop to my program but I'm not sure how to. here's what I have so far...

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
#include <iostream>
#include <math.h>

using namespace std;

int main()
{

double X,Y;
double resultPow,resultsin,resultCos,resulttan;
char userchoice;
char y,n;

cout<<"_____________________________"<<endl;
cout<<"{0-Quit                     }"<<endl;
cout<<"[1-Add                      ]"<<endl;
cout<<"[2-Subtract                 ]"<<endl;
cout<<"[3-multiply                 ]"<<endl;
cout<<"[4-Divide                   ]"<<endl;
cout<<"[5-raise X to the power Y   ]"<<endl;
cout<<"[6-Sin(X)                   ]"<<endl;
cout<<"[7-Cosine(X)                ]"<<endl;
cout<<"[8-Tangent(X)               ]"<<endl;
cout<<"_____________________________"<<endl;
cout<<"Please enter a slection"      <<endl;


int userChoice =0;
cin>>userchoice;

if (userchoice==1)
{
cout<<"please enter the first number, 'X'"<<endl;
cin>>X;
cout<<"please enter the second number, 'Y'"<<endl;
cin>>Y;
cout<<"results:"<<(X+Y)<<endl;
}

else if (userchoice==2)
{
cout<<"please enter the first number, 'X'"<<endl;
cin>>X;
cout<<"please enter the second number, 'Y'"<<endl;
cin>>Y;
cout<<"results:"<<(X-Y)<<endl;
}

else if (userchoice==3)
{
cout<<"please enter the number, 'X'"<<endl;
cin>>X;
cout<<"please enter the second number, 'Y'"<<endl;
cin>>Y;
cout<<"results:"<<(X*Y)<<endl;
}

else if (userchoice==4)
{
cout<<"please enter the first number, 'X'"<<endl;
cin>>X;
cout<<"please enter the second number, 'Y'"<<endl;
cin>>Y;
cout<<"results:"<<(X/Y)<<endl;
}

else if (userchoice==5)
{
cout<<"please enter the number, 'X'"<<endl;
cin>>X;
cout<<"please enter the degree of the power, 'Y'"<<endl;
cin>>Y;
resultPow = pow(X,Y);
cout<<"results:"<<(resultPow)<<endl;
}

else if (userchoice==6)
{
cout<<"please enter number, 'X'"<<endl;
cin>>X;
resultsin = sin (X*M_PI/180);
cout<<"results:"<<(sin (X*M_PI/180))<<endl;
}

else if (userchoice==7)
{
cout<<"please enter the first number, 'X'"<<endl;
cin>>X;
resultCos = cos (X*M_PI/180);
cout<<"results:"<<(cos (X*M_PI/180))<<endl;
}

else if (userchoice==8)
{
cout<<"please enter the first number, 'X'"<<endl;
cin>>X;
resulttan = (X*M_PI/180);
cout<<"results:"<<((X*M_PI/180))<<endl;
}

else if(userchoice == 0)
{
cout<<"Are you sure you want to quit? (Y/N)"<<endl;
cin>>userchoice;
   {
   if(userchoice == y);
   else if(userchoice == n);
   }
}
}
Topic archived. No new replies allowed.