Code

closed account (NUj6URfi)
When the loop is supposed to be repeated the program endlessly does cin.get();s. Why is that?

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
 #include <iostream>
#include <string>
using namespace std;

int i;
int z, x;
int k, l, r;

string a, dumb;

string plane[500];
int hop[500];
int mop[500];
int terminal[500];
int runway[500];

void menu();
void history();
void au();

void au() {
     z = 1;
     i = 0;
     cout << "This part of the A.T.C.P. allows you to put in the day's flight.\n The flights are then added to the history and this program also makes sure no \nplanes are going to to crash.\n When it asks for the flight you should type 'Flight111'.\n 111 being the flight number. When it is asking about the flight type 'Quit' to exit.\n Please restart the program every 500 planes.\n";
     while (z <= 500) {
           cout << "Flight?";
           getline(cin, plane[i]);
           if (plane[i] == "Quit.")
              menu();
           
x = 0;
while (x <= 499) {
      if (i << x) {
      plane[x] = "ahdrsdkjbnfciuwka"; }
if (i == x) {
x++;
}
if (plane[i] == plane[x]) {
cout << "Plane already logged.";
              cout << "Plane already registered. Closing.\n";
              menu();
}
              x++;}
cout << "Hour?";
cin >> hop[i];
cout << "Minutes?";
cin >> mop[i];
cout << "Terminal number?";
cin >> terminal[i];
cout << "Runway number?";
cin >> runway[i];
           
x = 0;
while (x <= 499) {
if (i == x) {
x++;
}
if (hop[i] == hop[x]) {
           
k = 0;
while (k <= 499) {
if (i == k) {
k++;
}
if (mop[i] == mop[k]) {
           
l = 0;
while (l <= 499) {
if (i == l) {
l++;
}
if (terminal[i] == terminal[l]) {
           
r = 0;
while (r <= 499) {
if (i == r) {
r++;
}
if (runway[i] == runway[r]) {
}
              }
cout << "Plane already for that time terminal and runway.\n\n";
}
              cout << "Closing.\n";
              menu();
              }

}
              }
              }
i++;
z++;
}
}
     cin.get();
     return;
}
int main() {
    i=0;
    menu();
    cin.get();
    cin.get();
    return 0;
}
void menu() {
    cout << "Welcome to the air traffic control program or A.T.C.P.. What would you like your A.T.C.P. do?\n You can view the history by typing 'History.' or edit incoming and landing \nflights by typing 'Active use.'\n\n";
    getline(cin, a);
    if (a == "History.") {
               history(); }
    if (a == "Active use.")
               au();
               while (a != "History." or "Active use.") {
                     cout << "\n Improper answer.\n";
                     getline(cin, a);
                      if (a == "History.") {
                         history(); }
                      if (a == "Active use.")
                         au();
                     }
}               
void history() {
               i = 0;
               while (i <= 100) {
                     if (i == 0) {
                           cout << "\nFlightNumber    Time    Terminal    Runway\n"; }
                     cout << plane[i]; 
                     cout << "       " << hop[i]; 
                     cout << ":" << mop[i]; 
                     cout << "    " << terminal[i]; 
                     cout << "       " << runway[i] << "\n";
                     i++;
                     }
    if (i == 101) {
         cout << "\nPress Enter to continue.\n";                 
    getline(cin, dumb); }
    while (i <= 200) {
                     if (i == 0) {
                           cout << "\nFlightNumber    Time    Terminal    Runway\n"; }
                     cout << plane[i]; 
                     cout << "       " << hop[i]; 
                     cout << ":" << mop[i]; 
                     cout << "    " << terminal[i]; 
                     cout << "       " << runway[i] << "\n";
                     i++;
                     }
    if (i == 201) {
         cout << "\nPress Enter to continue.\n";                 
    getline(cin, dumb); }
    while (i <= 300) {
                     if (i == 0) {
                           cout << "\nFlightNumber    Time    Terminal    Runway\n"; }
                     cout << plane[i]; 
                     cout << "       " << hop[i]; 
                     cout << ":" << mop[i]; 
                     cout << "    " << terminal[i]; 
                     cout << "       " << runway[i] << "\n";
                     i++;
                     }
    if (i == 301) {
         cout << "\nPress Enter to continue.\n";                 
    getline(cin, dumb); }
    while (i <= 400) {
                     if (i == 0) {
                           cout << "\nFlightNumber    Time    Terminal    Runway\n"; }
                     cout << plane[i]; 
                     cout << "       " << hop[i]; 
                     cout << ":" << mop[i]; 
                     cout << "    " << terminal[i]; 
                     cout << "       " << runway[i] << "\n";
                     i++;
                     }
    if (i == 401) {
         cout << "\nPress Enter to continue.\n";                 
    getline(cin, dumb); }
    while (i <= 499) {
                     if (i == 0) {
                           cout << "\nFlightNumber    Time    Terminal    Runway\n"; }
                     cout << plane[i]; 
                     cout << "       " << hop[i]; 
                     cout << ":" << mop[i]; 
                     cout << "    " << terminal[i]; 
                     cout << "       " << runway[i] << "\n";
                     i++;
                     }
               if (i == 500) {
                     cout << "History is finished.\n Returning to menu.\n";
                     }
    getline(cin, dumb);
    menu();
    cin.get();
    return;
}

Topic archived. No new replies allowed.