help i am really stuck, need someone to have a look at this ,
when u look at the 1,Reserve,suppose to ask u if want 1)first class or 2) Economy class,
but is not doing that and am getting errors
please can someone help
here is all the Errors
Error 7 error C2050: switch expression not integral c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp
studio 2008\projects\messiah\messiah\mess.cpp 106
Error 26 error C2065: 'i' : undeclared identifier c:\users\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 127
Error 27 error C2065: 'i' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 127
Error 29 error C2065: 'i' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 127
Error 33 error C2065: 'i' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 127
Error 34 error C2065: 'i' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 129
Error 1 error C2065: 'j' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 88
Error 2 error C2065: 'j' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 88
Error 3 error C2065: 'j' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 88
Error 9 error C2065: 'j' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 103
Error 12 error C2065: 'j' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 104
Error 25 error C2065: 'j' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 126
Error 28 error C2065: 'j' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 127
Error 31 error C2065: 'j' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 127
Error 35 error C2065: 'j' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp io 2008\projects\messiah\messiah\mess.cpp 130
Error 40 error C2065: 'j' : undeclared identifier c:\users\dentifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 114
Error 24 error C2065: 's' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 126
Error 30 error C2065: 's' : undeclared identifier c:\users\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 127
Error 32 error C2065: 's' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 127
Error 36 error C2065: 's' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 130
Error 39 error C2065: 's' : undeclared identifier c:\users\\documents\visual
studio 2008\projects\messiah\messiah\mess.cpp 136
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 232 233 234 235 236 237 238 239 240 241
|
#include <iostream>
#include <cctype>
#include <string>
#include <cstring>
using namespace std;
//Declare function proto type
int assignSeat(int seat_num, int row_num, int pass_num);
int num1(char);
int num(char);
int NumSeats = 10;
void InitializeSeats();
void Reserve();
void Cancel();
void ChangeSeat();
void Display();
struct Seat
{
char pass_name[80];
int Available;
};
struct Seat SeatArray[1][10];
int main()
{
char seatchioce = 0;
int row_num = 5;
char a = 0;
char w = 0;
int total_passenger = 10;
char arr1[][5] = {"1C","2A","3A","4A","5A",};
char arr2[][5] = {"6B","7B","8B","9B","10B",};
int MenuChoice;
InitializeSeats();
while(1)
{
cout << " 1. Reserve" << endl;
cout << " 2. Cancel" << endl;
cout << " 3. Change Seat" << endl;
cout << " 4. Display" << endl;
cout << " 5. Exit" << endl;
cout << "Enter your choice: ";
cin >> MenuChoice;
if((MenuChoice < 0) && (MenuChoice > 5))
{
cout << "Invalid Choice" << endl;
system("Pause Try Again");
}
else
{
switch(MenuChoice)
{
case 1: Reserve();
break;
case 2: Cancel();
break;
case 3: ChangeSeat();
break;
case 4: Display();
break;
case 5:
exit(1);
}
}
cin.get();
}
return 0;
}
void Reserve() //This function is for reserv the seats
{
int pass_num = 10;
cout << "Wellcome to Airline Passenger seat assignment" << endl;
cout <<"All"<< NumSeats << " seats are available " << endl;
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;
}
}
}
void Cancel()// This function is for Cancel the seat
{
char CancelPassengerName[80];
cout << "Enter the Passenger to be cancelled: ";
cin >> CancelPassengerName;
for(int i =0; i <5; i++)
{
for(int j=0; j<2; j++)
{
if(strcmp(SeatArray[i][j].pass_name, CancelPassengerName) == 0)
{
NumSeats++;
SeatArray[i][j].Available = 1;
return;
}
}
}
cout << " Passenger not in the list" << endl;
}
void ChangeSeat()//This function is for Change the seat
{
char MovePassenger[80];
int SeatRow, SeatColumn;
cout << "Enter the passenger name to be moved: ";
cin >> MovePassenger;
for(int i = 0; i < 5; i++)
{ for(int j = 0; j < 2; j++)
{
if(strcmp(SeatArray[i][j].pass_name, MovePassenger) == 0)
{
SeatRow = i;
SeatColumn = j;
}
}
}
if(NumSeats <= 0)
{
cout << "No seat available there for you cannot change seat" << endl;
return;
}
else{
for(int i = 0; i < 5; i++)
{
for(int j = 0; j < 2; j++)
{
if(SeatArray[i][j].Available == 1)
{
strcpy_s(SeatArray[i][j].pass_name, MovePassenger);
SeatArray[SeatRow][SeatColumn].Available = 1;
SeatArray[i][j].Available = 0;
return;
}
}
}
}
}
void Display()//Display the seat assingment for the all reservation
{
for(int i = 0; i < 5; i++)
{
for(int j = 0; j < 2; j++)
{
if(SeatArray[i][j].Available == 0)
{
cout << SeatArray[i][j].pass_name << " = " << i+1;
if (j == 0) { cout << "First Class" << endl; }
else { cout << "Economy Class" << endl; }
}
else
{
if(j == 1)
cout << i+1 << "Economy Class" << endl;
else
cout << i+1 << "first Class" << endl;
}
}
}
}
void InitializeSeats()//Initialy all seats are available
{
for(int i = 0; i < 5; i++)
{
for(int j = 0; j < 6; j++)
SeatArray[i][j].Available = 1;
}
}
|