please i need a big help with this c++ can anyone help me out

Hi i need a help please am doing my collage about airline reservation system in C++,but i keep get errors,this is my codes
#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(int i = 0; i < 10; i++)
{
for(int j = 0; j < 10; j++)
{
if(SeatArray[i][j].Available == 1)
{
cout << "Please enter the passenger name: ";
cin >> SeatArray[i][j].pass_name;
SeatArray[i][j].Available = 0;
NumSeats--;
return;
}
}

}
}
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;
}
}



but i need add codes so when u press 1, for Reserve,under reserve is going to ask the person to make a choice ,1,first class or 2 Ecomomy class,or how i can add this ur codes to it




#include "stdafx.h" //Not used in this code- Can be deleted.
#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;
}

please i will be really happy if u will be able to help me out
thanks
Last edited on
but i keep get errors

Such as...?
i need to add the 2nd part ,press 1, for Reserve

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;
}
}


please can u help me
Last edited on
can you edit your first post and use code tags, cos it's unreadable.
...
a small button <> on the right on this site represent a code tags..
Topic archived. No new replies allowed.