Expression creator, Please help

Please help me, I am trying to create an expression creator that prints the work out too, not just the answer.
Code:
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
#include <iostream>
#include <windows.h>
using namespace std;
void p1();
void p2();
void p3();
double P,P2,p,ans,ans2,ans1,restart;
char V;
int Pick,Pick2,Pick3,Parts;
int main()
{
while(restart!=2){
cout<<"How many steps are in this equation? (1 or 2)\n> ";
cin>>Parts;
switch(Parts){
case 1:
p1();
break;
case 2:
p2();
break;
case 3:
///p3();
break;}
cout<<"\n\nRestart?\n1) Yes\n2) No\n> ";
cin>>restart;
system("cls");
}}
Last edited on
More code:
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
void p1()
{
cout<<"EX:"<<endl;
    cout<<"\tW3===9"<<endl;
    cout<<"\t--  --"<<endl;
    cout<<"\t 3   3"<<endl;
    cout<<"\t------"<<endl;
    cout<<"\tW====3"<<endl;
    cout<<"______________________________________________"<<endl;
    cout<<"Please enter the variable letter: ";
    cin>>V;
    cout<<"\nPlease enter the number next to the variable: ";
    cin>>P;
    cout<<"\nPlease enter the answer: ";
    cin>>p;
    cout<<"\nWhat type of equation is this?\n1) Add\n2) Subtract\n3) Multiply\n4) Divide"<<endl;
    cin>>Pick;
    switch(Pick){
    case 4:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p*P;
    cout<<"\t"<<V<<"/"<<P<<"==="<<p<<endl;
    cout<<"\t*"<<P<<"    *"<<P<<endl;
    cout<<"\t---------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    case 3:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p/P;
    cout<<"\t"<<V<<P<<"==="<<p<<endl;
    cout<<"\t---  ---"<<endl;
    cout<<"\t "<<P<<"   "<<P<<endl;
    cout<<"\t---------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    case 2:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p+P;
    cout<<"\t"<<V<<"-"<<P<<"==="<<p<<endl;
    cout<<"\t+"<<P<<"   +"<<P<<endl;
    cout<<"\t--------"<<endl;
    cout<<"\t  "<<V<<"==="<<ans<<endl;
    break;
    case 1:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p-P;
    cout<<"\t"<<V<<"+"<<P<<"==="<<p<<endl;
    cout<<"\t-"<<P<<"   -"<<P<<endl;
    cout<<"\t--------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;}}
even more code:
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
188
189
190
191
192
193
194
195
void p2()
{
cout<<"EX:"<<endl;
    cout<<"\tW3+2===9"<<endl;
    cout<<"\t-----  --"<<endl;
    cout<<"\t 3     3"<<endl;
    cout<<"\t--------"<<endl;
    cout<<"\tW===== 3"<<endl;
    cout<<"\t-2    -2"<<endl;
    cout<<"\t--------"<<endl;
    cout<<"\tW===== 1"<<endl;
    cout<<"______________________________________________"<<endl;
    cout<<"Please enter the variable letter: ";
    cin>>V;
    cout<<"\nPlease enter the number next to the variable: ";
    cin>>P;
    cout<<"\nPlease enter the other number next to the variable: ";
    cin>>P2;
    cout<<"\nPlease enter the answer: ";
    cin>>p;
    cout<<endl<<"\t"<<V<<"_"<<P<<"_"<<P2<<"==="<<p<<endl;
    cout<<"\nWhat is equation type 1?\n1) Add\n2) Subtract\n3) Multiply\n4) Divide"<<endl;
    cin>>Pick;
    switch(Pick){
    case 4:
    cout<<"\t"<<V<<"/"<<P<<"_"<<2<<"==="<<p<<endl;
    cout<<"\nWhat is equation type 2?\n1) Add\n2) Subtract\n3) Multiply\n4) Divide"<<endl;
    cin>>Pick2;
    switch(Pick2){
    case 4:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p*P; ans=ans*P2;
    cout<<"\t"<<V<<"/"<<P<<"/"<<P2<<"==="<<p<<endl;
    cout<<"\t *"<<P<<"     *"<<P<<endl;
    cout<<"\t *"<<P2<<"     *"<<P2<<endl;
    cout<<"\t----------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    case 3:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p*P; ans=ans/P2;
    cout<<"\t"<<V<<"/"<<P<<"*"<<P2<<"==="<<p<<endl;
    cout<<"\t *"<<P<<"     *"<<P<<endl;
    cout<<"\t /"<<P<<"     /"<<P<<endl;
    cout<<"\t----------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    case 2:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p*P; ans=ans+P2;
    cout<<"\t"<<V<<"/"<<P<<"-"<<P2<<"==="<<p<<endl;
    cout<<"\t *"<<P<<"     *"<<P<<endl;
    cout<<"\t +"<<P2<<"     +"<<P2<<endl;
    cout<<"\t----------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    case 1:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p*P; ans=ans-P2;
    cout<<"\t"<<V<<"/"<<P<<"+"<<P2<<"==="<<p<<endl;
    cout<<"\t *"<<P<<"     *"<<P<<endl;
    cout<<"\t -"<<P2<<"     -"<<P2<<endl;
    cout<<"\t----------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    }
    break;
    case 3:
    cout<<"\nWhat is equation type 2?\n1) Add\n2) Subtract\n3) Multiply\n4) Divide"<<endl;
    cin>>Pick2;
    switch(Pick2){
    case 4:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p/P; ans=ans*P2;
    cout<<"\t"<<V<<"*"<<P<<"/"<<P2<<"==="<<p<<endl;
    cout<<"\t-----  --"<<endl;
    cout<<"\t "<<P<<"     "<<P<<endl;
    cout<<"\t *"<<P2<<"     *"<<P2<<endl;
    cout<<"\t----------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    case 3:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p/P; ans=ans/P2;
    cout<<"\t"<<V<<"*"<<P<<"*"<<P2<<"==="<<p<<endl;
    cout<<"\t-----  --"<<endl;
    cout<<"\t "<<P<<"     "<<P<<endl;
    cout<<"\t /"<<P<<"     /"<<P<<endl;
    cout<<"\t----------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    case 2:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p/P; ans=ans+P2;
    cout<<"\t"<<V<<"*"<<P<<"-"<<P2<<"==="<<p<<endl;
    cout<<"\t-----  --"<<endl;
    cout<<"\t "<<P<<"     "<<P<<endl;
    cout<<"\t +"<<P2<<"     +"<<P2<<endl;
    cout<<"\t----------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    case 1:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p/P; ans=ans-P2;
    cout<<"\t"<<V<<"*"<<P<<"+"<<P2<<"==="<<p<<endl;
    cout<<"\t-----  --"<<endl;
    cout<<"\t "<<P<<"     "<<P<<endl;
    cout<<"\t -"<<P2<<"     -"<<P2<<endl;
    cout<<"\t----------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    }
    break;
    case 2:
    cout<<"\nWhat is equation type 2?\n1) Add\n2) Subtract\n3) Multiply\n4) Divide"<<endl;
    cin>>Pick2;
    switch(Pick2){
    case 4:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p*P2; ans=ans+P;
    cout<<"\t"<<V<<"-"<<P<<"/"<<P2<<"==="<<p<<endl;
    cout<<"\t +"<<P<<"     +"<<P<<endl;
    cout<<"\t *"<<P2<<"     *"<<P2<<endl;
    cout<<"\t----------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    case 3:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=P*P2; ans=P+ans;
    cout<<"\t"<<V<<"-"<<P<<"*"<<P2<<"==="<<p<<endl;
    cout<<"\t +"<<P<<"     +"<<P<<endl;
    cout<<"\t /"<<P2<<"     /"<<P2<<endl;
    cout<<"\t----------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    case 2:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p+P; ans=ans+P2;
    cout<<"\t"<<V<<"-"<<P<<"-"<<P2<<"==="<<p<<endl;
    cout<<"\t +"<<P<<"     +"<<P<<endl;
    cout<<"\t +"<<P2<<"     +"<<P2<<endl;
    cout<<"\t----------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    case 1:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p+P; ans=ans-P2;
    cout<<"\t"<<V<<"-"<<P<<"+"<<P2<<"==="<<p<<endl;
    cout<<"\t +"<<P<<"     +"<<P<<endl;
    cout<<"\t -"<<P2<<"     -"<<P2<<endl;
    cout<<"\t----------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    }
    break;
    case 1:
    cout<<"\nWhat is equation type 2?\n1) Add\n2) Subtract\n3) Multiply\n4) Divide"<<endl;
    cin>>Pick2;
    switch(Pick2){
    case 4:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p*P2; ans=ans-P;
    cout<<"\t"<<V<<"+"<<P<<"/"<<P2<<"==="<<p<<endl;
    cout<<"\t -"<<P<<"     -"<<P<<endl;
    cout<<"\t *"<<P2<<"     *"<<P2<<endl;
    cout<<"\t----------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    case 3:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p/P2; ans=ans-P;
    cout<<"\t"<<V<<"+"<<P<<"*"<<P2<<"==="<<p<<endl;
    cout<<"\t -"<<P<<"     -"<<P<<endl;
    cout<<"\t /"<<P<<"     /"<<P<<endl;
    cout<<"\t----------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    case 2:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p-P; ans=ans+P2;
    cout<<"\t"<<V<<"+"<<P<<"-"<<P2<<"==="<<p<<endl;
    cout<<"\t -"<<P<<"     -"<<P<<endl;
    cout<<"\t +"<<P2<<"     +"<<P2<<endl;
    cout<<"\t----------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;
    case 1:
    cout<<"\nThe Equation is:\n"<<endl;
    ans=p-P; ans=ans-P2;
    cout<<"\t"<<V<<"+"<<P<<"+"<<P2<<"==="<<p<<endl;
    cout<<"\t -"<<P<<"     -"<<P<<endl;
    cout<<"\t -"<<P2<<"     -"<<P2<<endl;
    cout<<"\t----------"<<endl;
    cout<<"\t "<<V<<"==="<<ans<<endl;
    break;}break;}}
There is a problem with my math in void p2();, can anyone help?!
Last edited on
hello? anyone?
Topic archived. No new replies allowed.