[Help Please] looping

Write your question here.
hi there cplusplus comunity im new here and im having a problem with my cpp project
im doing a simple grading system but i have a problem on the looping here it is.

i want it to be when it ask me to exit and i press n i can type the names and grade again but this is what happen http://s1093.photobucket.com/user/troyzkie41/media/Untitled-1.jpg.html

any help will be apriciated thanks
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
  #include <iostream>
#include <conio.h>
#include <cmath>
#include <cstdlib>
using namespace std;
int main()

{
int i=0;
cout<<"\tAlvin Troy Dimafilis"<<"\n\tPassword Please: ";
char password[50]="";
string str="t",str2="Troyzkie";
char ch;

while(1)
{
ch=getch();
if(ch=='\b')
{
cout <<"\b \b"; if (i>0){password[i--]='\0';}
 }
else if (ch=='\n'|ch=='\r') {password[i]='\0'; break;}
else {password[i]=ch; i++; cout <<"$";} 
}

if (password==str){cout <<"\n\tGoodmorning! "<<str2<<"\n\n";}
else {cout <<"\n\n\t\t\tIntruders! Program will Exit\n\n";return 0;}

{
string a,b,c,d,e,f,g,h,yez;
int aa,bb,cc,dd,ee,ff,gg,hh;
cout<<"\t****************************************************************"<<endl;
cout<<"\t*\t\tRepublic of the Philippines\t\t       *"<<endl;
cout<<"\t*\t\tOccidental Mindoro State College\t       *\n\t*\t\t\t\t\t\t\t       *"<<endl;
cout<<"\t*      Jarvis 4.1\t\t\t\t\t       *"<<endl;
cout<<"\t*      Prototype Grading System\t\t\t\t       *\n\t*\t\t\t\t\t\t\t       *"<<endl;
cout<<"\t*   90-98 - Class A (Genues)\t\t\t\t       *"<<endl;
cout<<"\t*   87-89 - Class B (Smart)\t\t\t\t       *"<<endl;
cout<<"\t*   80-86 - Class C (Average)\t\t\t\t       *"<<endl<<"\t*\t\t\t\t\t\t\t       *"<<endl;
cout<<"\t****************************************************************"<<endl<<endl;
cout<<"\t****************************************************************"<<endl<<endl;
cout<<"\tName of Students"<<endl;
cout<<"\t";
getline(cin,a);
cout<<"\t";
getline(cin,b);
cout<<"\t";
getline(cin,c);
cout<<"\t";
getline(cin,d);
cout<<endl<<"\t****************************************************************"<<endl<<endl;

cout<<"\t"<<a<<"\t";
cin>>aa;

cout<<"\t"<<b<<"\t";
cin>>bb;

cout<<"\t"<<c<<"\t";
cin>>cc;

cout<<"\t"<<d<<"\t";

cin>>dd;

cout<<"\t\n\t****************************************************************"<<endl<<endl;
if(aa>89)
	{
		cout<<"\t"<<a<<"\t\t\tBelongs to Class A (Genius)\t     "<<aa<<endl;
	}
	else if(aa>86)
	{
		cout<<"\t"<<a<<"\t\t\tBelongs to Class B (Smart)\t     "<<aa<<endl;
	}
	else if (aa>79)
	{	
		cout<<"\t"<<a<<"\t\t\tBelongs to Class C (Average)\t     "<<aa<<endl;
	}
	else 
	{
		cout<<"\t"<<a<<"\t\tBelongs to below Class C (Below Average)     "<<aa<<endl;
	}
if(bb>89)
	{
		cout<<"\t"<<b<<"\t\t\tBelongs to Class A (Genius)\t     "<<bb<<endl;
	}
	else if(bb>86)
	{
		cout<<"\t"<<b<<"\t\t\tBelongs to Class B (Smart)\t     "<<bb<<endl;
	}
	else if (aa>79)
	{	
		cout<<"\t"<<b<<"\t\t\tBelongs to Class C (Average)\t     "<<bb<<endl;
	}
	else 
	{
	cout<<"\t"<<b<<"\t\tBelongs to below Class C (Below Average)     "<<bb<<endl;
	}
if(cc>89)
	{
		cout<<"\t"<<c<<"\t\t\tBelongs to Class A (Genius)\t     "<<cc<<endl;
	}
	else if(cc>86)
	{
		cout<<"\t"<<c<<"\t\t\tBelongs to Class B (Smart)\t     "<<cc<<endl;
	}
	else if (cc>79)
	{	
		cout<<"\t"<<c<<"\t\t\tBelongs to Class C (Average)\t     "<<cc<<endl;
	}
	else 
	{
	cout<<"\t"<<c<<"\t\tBelongs to below Class C (Below Average)     "<<cc<<endl;
	}
if(dd>89)
	{
		cout<<"\t"<<d<<"\t\t\tBelongs to Class A (Genius)\t     "<<dd<<endl;
	}
	else if(dd>86)
	{
		cout<<"\t"<<d<<"\t\t\tBelongs to Class B (Smart)\t     "<<dd<<endl;
	}
	else if (dd>79)
	{	
		cout<<"\t"<<d<<"\t\t\tBelongs to Class C (Average)\t     "<<dd<<endl;
	}
	else 
	{
	cout<<"\t"<<d<<"\t\tBelongs to below Class C (Below Average)     "<<dd<<endl;
	}
	cout<<"\n\n      Do you want to exit?(Y/N) ";
	cin>>yez;
	while (yez=="y"||yez=="Y")
	{
		cout<<"Doy you want to exit? ";
		cin>>yez;
		return 0;
	}
cout<<"\n\tName of Students"<<endl;
cout<<"\t";
getline(cin,a);
cout<<"\t";
getline(cin,b);
cout<<"\t";
getline(cin,c);
cout<<"\t";
getline(cin,d);

cout<<endl<<"\t****************************************************************"<<endl<<endl;

cout<<"\t"<<a<<"\t";
cin>>aa;

cout<<"\t"<<b<<"\t";
cin>>bb;

cout<<"\t"<<c<<"\t";
cin>>cc;

cout<<"\t"<<d<<"\t";

cin>>dd;

cout<<"\t\n\t****************************************************************"<<endl<<endl;
if(aa>89)
	{
		cout<<"\t"<<a<<"\t\t\tBelongs to Class A (Genius)\t     "<<aa<<endl;
	}
	else if(aa>86)
	{
		cout<<"\t"<<a<<"\t\t\tBelongs to Class B (Smart)\t     "<<aa<<endl;
	}
	else if (aa>79)
	{	
		cout<<"\t"<<a<<"\t\t\tBelongs to Class C (Average)\t     "<<aa<<endl;
	}
	else 
	{
		cout<<"\t"<<a<<"\t\tBelongs to below Class C (Below Average)     "<<aa<<endl;
	}
if(bb>89)
	{
		cout<<"\t"<<b<<"\t\t\tBelongs to Class A (Genius)\t     "<<bb<<endl;
	}
	else if(bb>86)
	{
		cout<<"\t"<<b<<"\t\t\tBelongs to Class B (Smart)\t     "<<bb<<endl;
	}
	else if (aa>79)
	{	
		cout<<"\t"<<b<<"\t\t\tBelongs to Class C (Average)\t     "<<bb<<endl;
	}
	else 
	{
	cout<<"\t"<<b<<"\t\tBelongs to below Class C (Below Average)     "<<bb<<endl;
	}
if(cc>89)
	{
		cout<<"\t"<<c<<"\t\t\tBelongs to Class A (Genius)\t     "<<cc<<endl;
	}
	else if(cc>86)
	{
		cout<<"\t"<<c<<"\t\t\tBelongs to Class B (Smart)\t     "<<cc<<endl;
	}
	else if (cc>79)
	{	
		cout<<"\t"<<c<<"\t\t\tBelongs to Class C (Average)\t     "<<cc<<endl;
	}
	else 
	{
	cout<<"\t"<<c<<"\t\tBelongs to below Class C (Below Average)     "<<cc<<endl;
	}
if(dd>89)
	{
		cout<<"\t"<<d<<"\t\t\tBelongs to Class A (Genius)\t     "<<dd<<endl;
	}
	else if(dd>86)
	{
		cout<<"\t"<<d<<"\t\t\tBelongs to Class B (Smart)\t     "<<dd<<endl;
	}
	else if (dd>79)
	{	
		cout<<"\t"<<d<<"\t\t\tBelongs to Class C (Average)\t     "<<dd<<endl;
	}
	else 
	{
	cout<<"\t"<<d<<"\t\tBelongs to below Class C (Below Average)     "<<dd<<endl;
	}
}

}	                               
1
2
3
4
5
6
	while (yez=="y"||yez=="Y")
	{
		cout<<"Doy you want to exit? ";
		cin>>yez;
		return 0;
	}

That doesn't handle the Enter key like the rest of the program does. I believe changing that to getline instead of cin should fix some of your issues.

Also, all of your code after that isn't a loop, it just gives the illusion of being a loop. If you learn a little more about conditional loops, it will put you on the right track.

The code is a little messy and hard to read. Have you learned about functions yet? It really helps readability and maintainability when functions are added properly.
thankyou for the answer sir ill try the cin and get back for some more info thanks again
Topic archived. No new replies allowed.