Do-While Issue

I Was Asked To Make A Basic Database (Project), Everything Works But The While Loop Doesnt Get Executed, Any Ways To Make It Work?

Here Is The 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
#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include<string.h>
#include<process.h>
#include<ctype.h>
struct criminal
{ int rn,id,age,yrs;
  char name[25],crime,des[100],dang,gng;
}c[100];

void main ()
{ clrscr();
char choice;
int choice2,n,i,srn,ch;

randomize();

cout<<"*******++++++WELCOME TO The F.B.I DATABASE++++++*******";
cout<<"\n\nPlease Wait";
sleep(1);
cout<<".";
sleep(1);
cout<<".";
sleep(1);
cout<<".";
sleep(1);
cout<<"\n\n\nWelcome To The F.B.I Criminal Record Page,Information Beyond This Point Is Highly Confidential,Are You Sure You Want To Continue?"<<"\tEnter Y To Continue ";
cin>>choice;
toupper(choice);
if (choice!='Y')
   { cout<<"\n\nOkay,Bye";
     cout<<"\nExiting";
     sleep(1);
     cout<<".";
     sleep(1);
     cout<<".";
     sleep(1);
     exit(0);
   }

     cout<<"\n\nLoading";
     sleep(1);
     cout<<"-";
     sleep(1);
     cout<<"-";
     sleep(1);
     cout<<"-";
     sleep(1);
   do
     { cout<<"\n\n*****Menu*****";
       cout<<"\n1.Enter A New Criminal";
       sleep(1);
       cout<<"\n\n2.Search For A Criminal";
       sleep(1);
       cout<<"\n\n3.Edit The Details Of An Inputted Criminal";
       sleep(1);
       cout<<"\n\n4.Exit ";
       sleep(1);
       cout<<"\n\nYour Choice? ";

       cin>>choice2;

     switch (choice2)
     {

     case 1:   cout<<"\nEnter The Number Of Criminals Whose Record Is To Be Created ";
	       cin>>n;
	       for(i=0;i<n;i++)
		  { cout<<"\n\nEnter The Full Name Of The Criminal- ";
		    cin.getline(c[i].name,25);
		    cout<<"\nEnter Age Of The Criminal ";
		    cin>>c[i].age;
		    cout<<"\nEnter The Criminal Record Number- ";
		    cin>>c[i].rn;
		    c[i].id=random(1000+100);
		    cout<<"\nEnter The Number Of Years Sentenced- ";
		    cin>>c[i].yrs;
		    cout<<"\nIs The Criminal Certified Dangerous? (Y/N) ";
		    cin>>c[i].dang;
		    cout<<"\nIs The Criminal A Gangster? ";
		    cin>>c[i].gng;
		    cout<<"\nCriminal Description- ";
		    cin.getline(c[i].des,100);
		    cout<<"\nProcessing";
		    sleep(1);
		    cout<<".";
		    sleep(1);
		    cout<<".";
		    sleep(1);
		    cout<<"\nGenerating ID Number";
		    sleep(1);
		    cout<<".";
		    sleep(1);
		    cout<<".";
		    sleep(1);
		    cout<<"\nFinalizing";
		    sleep(1);
		    cout<<".";
		    sleep(1);
		    cout<<".";
		    sleep(1);
		    cout<<".";
		    sleep(1);

		   }
	       break;

     case 2:   cout<<"\nEnter The Criminal Record Number Of The Criminal- ";
	       cin>>srn;
	       cout<<"\nSearching";
	       sleep(1);
	       cout<<".";
	       sleep(1);
	       cout<<".";
	       sleep(1);
	       for (i=0;i<n;i++)
		   { if(srn==c[i].rn)
		       { cout<<"\n\nThe Full Name Of The Criminal- ";
			 cout<<c[i].name;
			 cout<<"\nAge Of The Criminal ";
			 cout<<c[i].age;
			 cout<<"\nThe Criminal Record Number- ";
			 cout<<c[i].rn;
			 cout<<c[i].id;
			 cout<<"\nThe Number Of Years Sentenced- ";
			 cout<<c[i].yrs;
			 cout<<"\nCriminal Certified Dangerous? (Y/N) ";
			 cout<<c[i].dang;
			 cout<<"\nThe Criminal A Gangster ";
			 cout<<c[i].gng;
			 cout<<"\nCriminal Description- ";
			 cout<<c[i].des;
		       }
		     else
		       { cout<<"The Searched Criminal Does Not Exist";
		       }
		   }
		   break;

     case 3:   cout<<"\nEnter The Criminal Record Number Of The Criminal- ";
	       cin>>srn;
	       cout<<"\nSearching";
	       sleep(1);
	       cout<<".";
	       sleep(1);
	       cout<<".";
	       sleep(1);
	       for (i=0;i<n;i++)
		   { if(srn==c[i].rn)
		       { cout<<"\nEnter Age Of The Criminal ";
			 c[i].age;
			 cout<<"\nCriminal Description- ";
			 cin>>c[i].des;
			 cout<<"Updating";
			 sleep(2);
			 cout<<".";
			 sleep(1);
			 cout<<".";
			 sleep(1);
			 cout<<"\nDetails Updated.";

		       }
		     else
		       { cout<<"The Searched Criminal Does Not Exist";
		       }
		   }
		   break;

     case 4:   cout<<"\n\nOkay,Bye";
	       cout<<"\nExiting";
	       sleep(1);
	       cout<<".";
	       sleep(1);
	       cout<<".";
	       sleep(1);
	       exit(0);
	       break;

     default:  cout<<"The Inputted Choice Is Wrong ";
	       break;


     }
     }

	       while(choice2!=4);



      getch();

 }


Last edited on
Duplicate thread: http://www.cplusplus.com/forum/beginner/184283/

Please don't spam the forum with multiple threads on the same topic. It's unhelpful, and wastes peoples' time.
Topic archived. No new replies allowed.