can someone have a look and tell me where am goin wrong
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
|
#include <string>
#include <iostream>
using namespace std;
int main()
{
int c, s[10];
int i, j;
string name;
cout << "Welcome to Airline Reservations System!\n";
for (j=0; j<10; j++)
{
cout << "Please enter your name: ";
getline(cin,name);
cout << "Choose a class: ";
cin >> c;
switch(c)
{
case 1:
cout << "First class" << endl;
cout << "Seats available are 1,2,3,4,5.\n";
do {
cout << "Pick a seat: ";
cin >> s[j];
for (i=0; i<j; i++) if (s[j]==s[i]) {cout << "Seat taken. ";
break;}
} while (i!=j);
if(s[j] <= 5)
{
cout << "\n";
cout <<" \n";
cout << "Name: " << name << endl;
cout << "Class: " << "First class" << endl;
cout << "Seat no.: " << s << endl;
cout << "\n";
}
else
cout << "Wrong number! No seat for you!\n";
break;
case 2:
cout << "Economic class\n";
cout << "Seats available are 6,7,8,9,10.\n";
do {
cout << "Pick a seat number: ";
cin >> s[j];
for (i=0; i<j; i++) if (s[j]==s[i]) {cout << "Seat taken. ";
break;}
} while (i!=j);
if(s[j] >= 6)
{
cout << "\n";
cout << "\n";
cout << "Name: " << name << endl;
cout << "Class: " << "Economic class" << endl;
cout << "Seat no.: " << s[j] << endl;
cout << "\n";
}
else
cout << "Wrong number! No seat for you!\n";
break;
default:
break;
}
}
system("pause");
return 0;
}
|
when you enter the first name it will fine ,but u when u enter the 2nd name
Last edited on
Ummm. Whats the problem again? haha.