program about are you smarter than a 5th grader

Pages: 12
//can someone finish my program about are you smarter than a 5th grader? btw i already put the answers up, i dont know what should I do next, please help me, im on the verge of failing my program


#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
int main()
{
string name;
int age,A,subject,animal,answer1,A1;
char play,another,N,n,Y,y,ans,g,G,I,i,X,x,C1,help;
cout<<" ";
cout<<" ";
cout<<" ";
cout<<" ** * ** ***** ** ****** ******* ** ** ***** ";
cout<<" ** * * ** ** ** * * * ** * * ** ** ";
cout<<" ** ** ***** ******* ****** ******* ** * ** ***** ";
cout<<" ";
cout<<" Are you smarter than a 5th grader? ";
cout<<" ";
cout<<" ";
cout<<"\n";
cout<<"Enter name: ";
cin>>name;
cout<<"Enter age: ";
cin>>age;
system("cls");
cout<<"Press [G] for start, [I] for instructions, [X] for exit: ";
cin>>ans;
if(ans=='G'||ans=='g'){
system("cls");
cout<<" [1] Grade 1 Civics and Culture [2] Grade 1 Filipino\n\n [3] Grade 2 English\t\t [4] Grade 2 Math\n\n [5] Grade 3 Civics and Culture [6] Grade 3 Math\n\n [7] Grade 4 History\t\t [8] Grade 4 MAPEH\n\n [9] Grade 5 Science\t\t [10] Grade 5 English\n\n";
cout<<"\nPlease select your subject: ";
cin>>subject;
system("cls");
switch(subject){
case 1: cout<<"Complete the quote below:\n\n"; //answer dito ay: animal
cout<<" He who does not love his own language is worse than an _____ and smelly fish\n\n";
cout<<"Do you need help?[y/n]: ";
cin>>help;
if(help=='Y'||help=='y'){
cout<<"[P] for peek\n[C] for copy\n[S] for save\n";
cout<<"Enter your choice: ";
cin>>C1;
{
if(C1=='P'||C1=='p'){
cout<<"The answer is animal";
cout<<"\nEnter your answer: ";
cin>>A1;
{ if(A1==animal)
cout<<"Correct!";

else(A1!=animal);
cout<<"Wrong answer";

}
}
if(C1=='C'||C1=='c'){
cout<<"Correct! The answer is animal ";
}
if(C1=='S'||C1=='s'){
cout<<"Enter your answer: ";
cin>>A;
cout<<"Correct! The answer is animal";
}
}
}
if(help=='N'||help=='n'){
cout<<"Enter your answer: ";
cin>>A1;
{
if(A1==animal)
cout<<"Correct!";

if(A1!=animal)
cout<<"Wrong answer";

}
}

break;
case 2: cout<<"A part of a friendly letter where it states the adress of the writer and the date it was made\n\n"; //answer dito ay heading
break;
case 3: cout<<"True or False:\n\n"; //answer dito ay true
cout<<"When the plural of a noun shows possession or ownership, it is in its plural possessive form\n\n";
break;
case 4: cout<<"Fill in the blanks:\n\n";
cout<<"Mental Computation through estimation is done by rounding off a number to its_____ _____ _____\n\n"; //answer dito ay highest place value
break;
case 5: cout<<"What is the imaginary line that divides the globe into Northern Hemisphere and Southern Hemisphere.\n\n"; //answer dito ay equator
break;
case 6: cout<<"Fill in the blanks:\n\n";
cout<<"Fractions representing numbers equal to ____ have the same numerator and denominator\n\n"; //answer dito ay one
break;
case 7: cout<<"Region 4-A are consists of Quezon,Rizal,Cavite,Laguna,and Batangas. What is the name of these five provinces?\n\n"; //answer dito ay calabarzon
break;
case 8: cout<<"In Music, what is composed of 5 lines and four spaces?\n\n";
break;
case 9: cout<<"Under which sub-group of invertebrate animals do the clam, squid, octopus and snail belong?\n\n"; //answer dito ay mollusks
break;
case 10: cout<<"What type of adjectives expresses qualities of nouns and pronouns?\n\n"; //answer dito ay descriptive adjectives
break;
}
}
if(ans=='I'||ans=='i'){
system("cls");
cout<<"This game will ask questions to you with general knowledge questions. The more questions you answers correctly, the longer you stay in the game. The questions asked to you increase in difficulty, starting with first-grade level and progressing in difficulty up to questions from a fifth-grade curriculum. The player earns a PHP 1,000 for each question he answers correctly. Just one wrong answer and you will be eliminated from the game. Don't worry, you have three lifelines that can save you, these are the peek,copy, and save.\n\n Peek - this lifeline will allow you to see the answer, but it will still depend on you if you will copy it or not\n\n Copy - this lifeline will automatically copy the right answer\n\n Save - this lifeline will automatically save you even if you write the wrong answer";
cout<<"\n\n\nDo you want now to play the game?[y/n]: ";
cin>>play;
}
{
if(play=='Y'||play=='y'){

cout<<"Enter name: ";
cin>>name;
cout<<"Enter age: ";
cin>>age;
system("cls");
cout<<" [1] Grade 1 Civics and Culture [2] Grade 1 Filipino\n [3] Grade 2 English\t\t [4] Grade 2 Math\n [5] Grade 3 Civics and Culture [6] Grade 3 Math\n [7] Grade 4 History\t\t [8] Grade 4 MAPEH\n [9] Grade 5 Science\t\t [10] Grade 5 English\n";
cout<<"\nPlease select your subject: ";
cin>>subject;
system("cls");
switch(subject){
case 1: cout<<"Complete the quote below:\n\n"; //answer dito ay: animal
cout<<" He who does not love his own language is worse than an _____ and smelly fish\n\n";
cout<<"Do you need help?[y/n]: ";
cin>>help;
if(help=='Y'||help=='y'){
cout<<"[P] for peek\n[C] for copy\n[S] for save\n";
cout<<"Enter your choice: ";
cin>>C1;
{
if(C1=='P'||C1=='p'){
cout<<"The answer is animal";
cout<<"\nEnter your answer: ";
cin>>A1;
{ if(A1==animal)
cout<<"Correct!";

else(A1!=animal);
cout<<"Wrong answer";

}
}
if(C1=='C'||C1=='c'){
cout<<"Correct! The answer is animal ";
}
if(C1=='S'||C1=='s'){
cout<<"Enter your answer: ";
cin>>A;
cout<<"Correct! The answer is animal";
}
}
}
if(help=='N'||help=='n'){
cout<<"Enter your answer: ";
cin>>A1;
{
if(A1==animal)
cout<<"Correct!";

if(A1!=animal)
cout<<"Wrong answer";

}
}
break;
case 2: cout<<"A part of a friendly letter where it states the adress of the writer and the date it was made\n\n"; //answer dito ay heading
break;
case 3: cout<<"True or False:\n\n"; //answer dito ay true
cout<<"When the plural of a noun shows possession or ownership, it is in its plural possessive form\n\n";
break;
case 4: cout<<"Fill in the blanks:\n\n";
cout<<"Mental Computation through estimation is done by rounding off a number to its_____ _____ _____\n\n"; //answer dito ay highest place value
break;
case 5: cout<<"What is the imaginary line that divides the globe into Northern Hemisphere and Southern Hemisphere.\n\n"; //answer dito ay equator
break;
case 6: cout<<"Fill in the blanks:\n\n";
cout<<"Fractions representing numbers equal to ____ have the same numerator and denominator\n\n"; //answer dito ay one
break;
case 7: cout<<"Region 4-A are consists of Quezon,Rizal,Cavite,Laguna,and Batangas. What is the name of these five provinces?\n\n"; //answer dito ay calabarzon
break;
case 8: cout<<"In Music, what is composed of 5 lines and four spaces\n\n?"; //answer dito ay staff
break;
case 9: cout<<"Under which sub-group of invertebrate animals do the clam, squid, octopus and snail belong?\n\n"; //answer dito ay mollusks
break;
case 10: cout<<"What type of adjectives expresses qualities of nouns and pronouns?\n\n"; //answer dito ay descriptive adjectives
break;
}
}
if(play=='N'||play=='n')
cout<<"Ok thank you!";
}
if(ans=='X'||ans=='x'){
cout<<"BYE!\n";
}

return 0;
}
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
196
197
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
int main()
{
string name;
int age,A,subject,animal,answer1,A1;
char play,another,N,n,Y,y,ans,g,G,I,i,X,x,C1,help;
cout<<" ";
cout<<" ";
cout<<" ";
cout<<" ** * ** ***** ** ****** ******* ** ** ***** ";
cout<<" ** * * ** ** ** * * * ** * * ** ** ";
cout<<" ** ** ***** ******* ****** ******* ** * ** ***** ";
cout<<" ";
cout<<" Are you smarter than a 5th grader? ";
cout<<" "; 
cout<<" ";
cout<<"\n";
cout<<"Enter name: ";
cin>>name;
cout<<"Enter age: ";
cin>>age;
system("cls");
cout<<"Press [G] for start, [I] for instructions, [X] for exit: ";
cin>>ans;
if(ans=='G'||ans=='g'){
system("cls");
cout<<" [1] Grade 1 Civics and Culture [2] Grade 1 Filipino\n\n [3] Grade 2 English\t\t [4] Grade 2 Math\n\n [5] Grade 3 Civics and Culture [6] Grade 3 Math\n\n [7] Grade 4 History\t\t [8] Grade 4 MAPEH\n\n [9] Grade 5 Science\t\t [10] Grade 5 English\n\n";
cout<<"\nPlease select your subject: ";
cin>>subject;
system("cls");
switch(subject){
case 1: cout<<"Complete the quote below:\n\n"; //answer dito ay: animal
cout<<" He who does not love his own language is worse than an _____ and smelly fish\n\n";
cout<<"Do you need help?[y/n]: ";
cin>>help;
if(help=='Y'||help=='y'){
cout<<"[P] for peek\n[C] for copy\n[S] for save\n";
cout<<"Enter your choice: ";
cin>>C1;
{
if(C1=='P'||C1=='p'){
cout<<"The answer is animal";
cout<<"\nEnter your answer: ";
cin>>A1;
{	if(A1==animal)
cout<<"Correct!";

else(A1!=animal);
cout<<"Wrong answer";

}
}
if(C1=='C'||C1=='c'){
cout<<"Correct! The answer is animal ";
}
if(C1=='S'||C1=='s'){
cout<<"Enter your answer: ";
cin>>A;
cout<<"Correct! The answer is animal";
}
}
}
if(help=='N'||help=='n'){
cout<<"Enter your answer: ";
cin>>A1;
{
if(A1==animal)
cout<<"Correct!";

if(A1!=animal)
cout<<"Wrong answer";

}
}

break;
case 2: cout<<"A part of a friendly letter where it states the adress of the writer and the date it was made\n\n"; //answer dito ay heading
break;
case 3: cout<<"True or False:\n\n"; //answer dito ay true
cout<<"When the plural of a noun shows possession or ownership, it is in its plural possessive form\n\n";
break;
case 4: cout<<"Fill in the blanks:\n\n";
cout<<"Mental Computation through estimation is done by rounding off a number to its_____ _____ _____\n\n"; //answer dito ay highest place value
break;
case 5: cout<<"What is the imaginary line that divides the globe into Northern Hemisphere and Southern Hemisphere.\n\n"; //answer dito ay equator
break;
case 6: cout<<"Fill in the blanks:\n\n";
cout<<"Fractions representing numbers equal to ____ have the same numerator and denominator\n\n"; //answer dito ay one
break;
case 7: cout<<"Region 4-A are consists of Quezon,Rizal,Cavite,Laguna,and Batangas. What is the name of these five provinces?\n\n"; //answer dito ay calabarzon
break;
case 8: cout<<"In Music, what is composed of 5 lines and four spaces?\n\n";
break;
case 9: cout<<"Under which sub-group of invertebrate animals do the clam, squid, octopus and snail belong?\n\n"; //answer dito ay mollusks
break;
case 10: cout<<"What type of adjectives expresses qualities of nouns and pronouns?\n\n"; //answer dito ay descriptive adjectives
break;
}	
}
if(ans=='I'||ans=='i'){
system("cls");
cout<<"This game will ask questions to you with general knowledge questions. The more questions you answers correctly, the longer you stay in the game. The questions asked to you increase in difficulty, starting with first-grade level and progressing in difficulty up to questions from a fifth-grade curriculum. The player earns a PHP 1,000 for each question he answers correctly. Just one wrong answer and you will be eliminated from the game. Don't worry, you have three lifelines that can save you, these are the peek,copy, and save.\n\n Peek - this lifeline will allow you to see the answer, but it will still depend on you if you will copy it or not\n\n Copy - this lifeline will automatically copy the right answer\n\n Save - this lifeline will automatically save you even if you write the wrong answer";
cout<<"\n\n\nDo you want now to play the game?[y/n]: ";
cin>>play;
}
{
if(play=='Y'||play=='y'){

cout<<"Enter name: ";
cin>>name;
cout<<"Enter age: ";
cin>>age;
system("cls");
cout<<" [1] Grade 1 Civics and Culture [2] Grade 1 Filipino\n [3] Grade 2 English\t\t [4] Grade 2 Math\n [5] Grade 3 Civics and Culture [6] Grade 3 Math\n [7] Grade 4 History\t\t [8] Grade 4 MAPEH\n [9] Grade 5 Science\t\t [10] Grade 5 English\n";
cout<<"\nPlease select your subject: ";
cin>>subject;
system("cls");
switch(subject){
case 1: cout<<"Complete the quote below:\n\n"; //answer dito ay: animal
cout<<" He who does not love his own language is worse than an _____ and smelly fish\n\n";
cout<<"Do you need help?[y/n]: ";
cin>>help;
if(help=='Y'||help=='y'){
cout<<"[P] for peek\n[C] for copy\n[S] for save\n";
cout<<"Enter your choice: ";
cin>>C1;
{
if(C1=='P'||C1=='p'){
cout<<"The answer is animal";
cout<<"\nEnter your answer: ";
cin>>A1;
{	if(A1==animal)
cout<<"Correct!";

else(A1!=animal);
cout<<"Wrong answer";

}
}
if(C1=='C'||C1=='c'){
cout<<"Correct! The answer is animal ";
}
if(C1=='S'||C1=='s'){
cout<<"Enter your answer: ";
cin>>A;
cout<<"Correct! The answer is animal";
}
}
}
if(help=='N'||help=='n'){
cout<<"Enter your answer: ";
cin>>A1;
{
if(A1==animal)
cout<<"Correct!";

if(A1!=animal)
cout<<"Wrong answer";

}
}
break;
case 2: cout<<"A part of a friendly letter where it states the adress of the writer and the date it was made\n\n"; //answer dito ay heading
break;
case 3: cout<<"True or False:\n\n"; //answer dito ay true
cout<<"When the plural of a noun shows possession or ownership, it is in its plural possessive form\n\n";
break;
case 4: cout<<"Fill in the blanks:\n\n";
cout<<"Mental Computation through estimation is done by rounding off a number to its_____ _____ _____\n\n"; //answer dito ay highest place value
break;
case 5: cout<<"What is the imaginary line that divides the globe into Northern Hemisphere and Southern Hemisphere.\n\n"; //answer dito ay equator
break;
case 6: cout<<"Fill in the blanks:\n\n";
cout<<"Fractions representing numbers equal to ____ have the same numerator and denominator\n\n"; //answer dito ay one
break;
case 7: cout<<"Region 4-A are consists of Quezon,Rizal,Cavite,Laguna,and Batangas. What is the name of these five provinces?\n\n"; //answer dito ay calabarzon
break;
case 8: cout<<"In Music, what is composed of 5 lines and four spaces\n\n?"; //answer dito ay staff
break;
case 9: cout<<"Under which sub-group of invertebrate animals do the clam, squid, octopus and snail belong?\n\n"; //answer dito ay mollusks
break;
case 10: cout<<"What type of adjectives expresses qualities of nouns and pronouns?\n\n"; //answer dito ay descriptive adjectives
break;
}
}
if(play=='N'||play=='n')
cout<<"Ok thank you!";
}
if(ans=='X'||ans=='x'){
cout<<"BYE!\n";
}

return 0;
}
I copied your code into a code tags so it shows line numbers.

One of many problem that you have is that the answers given by the player are strings and when you compare stings in if statement let's say in line 157 it should be if(A1=="animal") animal in double quotes. But that will not work because you declared all the answers as int and you can not compare int to a string.

In line 8 you should change everything that is an answer to a string:
1
2
int age, subject;
string A,animal,answer1,A1;


Do that and then tell us about problems that you have, we'll take it from there
//thank you for your response :D can you help me in case 2 to 10, it doesnt show the question do you need help?


case 2: cout<<"A part of a friendly letter where it states the adress of the writer and the date it was made\n\n";

//answer dito ay heading
cout<<"Do you need help?[y/n]: ";
cin>>help;
if(help=='Y'||help=='y'){
cout<<"[P] for peek\n[C] for copy\n[S] for save\n";
cout<<"Enter your choice: ";
cin>>C1;
{
if(C1=='P'||C1=='p'){
cout<<"The answer is heading";
cout<<"\nEnter your answer: ";
cin>>A;
{ if(A1=="heading")
cout<<"Correct!";

else(A1!="heading");
cout<<"Wrong answer";

}
}
if(C1=='C'||C1=='c'){
cout<<"Correct! The answer is heading ";
}
if(C1=='S'||C1=='s'){
cout<<"Enter your answer: ";
cin>>A;
cout<<"Correct! The answer is heading";
}
}
}
if(help=='N'||help=='n'){
cout<<"Enter your answer: ";
cin>>A1;
{
if(A1=="heading")
cout<<"Correct!";

if(A1!="heading")
cout<<"Wrong answer";

}
}
break;
Last edited on
from case 2 - 10 you only output a question, you don't even give an option of entering an answer (in the original code you posted)

so you need to repeat what you did in case 1, (which is what you are showing now in your second post)

even better, make the help option into a function and call it in every case, much less tying and repeating of the same thing.
also with your if statements when there are only to options like the answer can be correct or not you don't need to give a condition the second time

as in
1
2
3
4
5
if(A1=="heading")
cout<<"Correct!";

if(A1!="heading")
cout<<"Wrong answer";


should be
1
2
3
4
if (A1 == "heading")
cout << "Correct!";
else
cout << "Wrong answer"; 
// i already done my mp. thank you so much, i'm now in the hardest part of my program, how would it return to the main menu(where all the subjects are) if the user answers correctly the problem and also it should display a menu without the subject the user answered already, the lifelines must also be disappeared after getting used.

thanks ! :D
The best thing to go back to main menu is a loop, since you didn't think about it I will presume you don't know what loops are, so try this link:

http://www.cprogramming.com/tutorial/lesson3.html

Since you display the categories as a single output it would be hard to take out the one they already answered.

So you could keep record of number of questions they already answered and if they select it again it will not be accepted. That would mean a loop again, so if they already answered question 1 and then again they try to choose 1 the loop will take them back to the select your category option
What's a lifeline?
thank you so much :D !! i already did what i understand in the looping system. Example, when user answer question 1 correctly, it will display again the list of subjects (this is what should this program really be) but when the user picks question 1 again, it should not be open, because it is already answered, and also, lifelines are the peek, copy, and save i put to help the user, but it should not be display again when it is already been use. How should i do that ?


thanks :D
btw, i cant post my latest work here, it says too long :(
I think I'd use boolean, say declare new bool bool lifelineUsed = false;

rap up the question about getting help in if statemt:

1
2
3
4
5
6
7
8
 if (lifelineUsed == false){
cout<<"Do you need help?[y/n]: ";
cin>>help;}

if(help=='Y' || help=='y'){
lifelineUsed = true;
//plus all the other things you have in this if statement
}
you could also post portion of your code that you have a problem with, you don't have to post the whole thing every time. If you do that, can you please put code in code tags, you can find it on the right of where you are typing. It't the first one and it looks like this <>, it makes the code easier to read.
thx
this is my part of the code, question 1 and question 2, lets say user use peek on the question 1 to get the right answer, then the main menu will show up again, so when user 1 picks question 1 again it should not be open, and also when user picks question 2 he cant use peek either

again, thanks for the help ! :D



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
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
int main()
{
string A,animal,correct,heading,A1,answer1,name;
int age,subject;
char play,another,N,n,Y,y,ans,g,G,I,i,X,x,C1,help;

cout<<"Enter name (first name only): ";
cin>>name;
cout<<"Enter age: ";
cin>>age;
system("cls");
cout<<"Press [I] for instructions, [G] for start, [X] for exit: ";
cin>>ans;
if(ans=='G'||ans=='g'){
	while(A1==correct){
system("cls");
cout<<" [1] Grade 1 Civics and Culture [2] Grade 1 Filipino\n\n [3] Grade 2 English\t\t [4] Grade 2 Math\n\n [5] Grade 3 Civics and Culture [6] Grade 3 Math\n\n [7] Grade 4 History\t\t [8] Grade 4 MAPEH\n\n [9] Grade 5 Science\t\t [10] Grade 5 English\n\n";
cout<<"\nPlease select your subject: ";
cin>>subject;
system("cls");
switch(subject){
case 1: cout<<"Complete the quote below:\n\n"; //answer dito ay: animal
cout<<" He who does not love his own language is worse than an _____ and smelly fish\n\n";
cout<<"Do you need help?[y/n]: ";
cin>>help;
if(help=='Y'||help=='y'){
cout<<"[P] for peek\n[C] for copy\n[S] for save\n";
cout<<"Enter your choice: ";
cin>>C1;
{
if(C1=='P'||C1=='p'){
cout<<"The answer is animal";
cout<<"Enter your answer: ";
cin>>A1;
correct="animal";
{
if(A1==correct)
cout<<"Correct!";

if(A1!=correct)
cout<<"Wrong answer";

}
}
if(C1=='C'||C1=='c'){
cout<<"Correct! The answer is animal ";
}
if(C1=='S'||C1=='s'){
cout<<"Enter your answer: ";
cin>>A;
cout<<"Correct! The answer is animal";
}
}
}
if(help=='N'||help=='n'){
cout<<"Enter your answer: ";
cin>>A1;
correct="animal";
{
if(A1==correct)
cout<<"Correct!";

if(A1!=correct)
cout<<"Wrong answer";

}
}

break;
case 2: cout<<"A part of a friendly letter where it states the adress of the writer and the date it was made\n\n"; //answer dito ay heading
cout<<"Do you need help?[y/n]: ";
cin>>help;
if(help=='Y'||help=='y'){
cout<<"[P] for peek\n[C] for copy\n[S] for save\n";
cout<<"Enter your choice: ";
cin>>C1;
{
if(C1=='P'||C1=='p'){
cout<<"The answer is heading";
cout<<"Enter your answer: ";
cin>>A1;
correct="heading";
{
if(A1==correct)
cout<<"Correct!";

if(A1!=correct)
cout<<"Wrong answer";

}
}
if(C1=='C'||C1=='c'){
cout<<"Correct! The answer is heading ";
}
if(C1=='S'||C1=='s'){
cout<<"Enter your answer: ";
cin>>A;
cout<<"Correct! The answer is heading";
}
}
}
if(help=='N'||help=='n'){
cout<<"Enter your answer: ";
cin>>A1;
correct="heading";
{
if(A1==correct)
cout<<"Correct!";

if(A1!=correct)
cout<<"Wrong answer";

}
}
break;
}
}
}
return 0;
}
Last edited on
so if user asks for help they get to peek, copy or save. Is each option available once? Therefore they can ask for help 3 times?

If so, then you could have 3 bools for peek used, copy used and save used, but then you would need to code each help option in a separate cout

as in if they select Y for help it would have to look something like:
1
2
3
4
5
if (peekUsed == false)
cout << "[P] for peek\n";
if (copyUsed == false)
cout << [C] for Copy\n";
//etc.. 


//should i write this also in the top with the int string and char?

1
2
3
4
5
6
string A,animal,correct,heading,A1,answer1,name;
int age,subject;
char play,another,N,n,Y,y,ans,g,G,I,i,X,x,C1,help;
bool peekUsed=false;
bool copyUsed=false;
bool saveUsed=false;



and like this? hehehe

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
case 1: cout<<"Complete the quote below:\n\n"; //answer dito ay: animal
cout<<" He who does not love his own language is worse than an _____ and smelly fish\n\n";
cout<<"Do you need help?[y/n]: ";
cin>>help;
if(help=='Y'||help=='y'){
if (peekUsed == false)
cout << "[P] for peek\n";
if (copyUsed == false)
cout << "[C] for Copy\n";
if(saveUsed == false)
cout<<"[S] for Save\n";


cout<<"Enter your choice: ";
cin>>C1;


Last edited on
that's right, you have to declare bool with other variables
you can also declare it in one line bool peekUsed = false, copyUsed = false, saveUsed = false;

its not a big deal, it will just save 2 lines of code

are you happy now with your program?
nothing changed

i can still use the three lifelines in every question
hahahah
in the part of your code where they selected yes to help, they get to input 'p', 'c', 's'

say they select 'p'

1
2
3
4
if(C1=='P'||C1=='p'){
cout<<"The answer is animal";
peekUsed = true; // don't forget to change peekUsed to true
}
woah ! it works :D thank you very much :)

btw, my last problem is how i stop my user to pick again questions they already answered correctly ?
Pages: 12