Hello,
i already have C++ class few month , but i still find difficult to write the problem analysis on this project ...
This is my question ...

"Problem Specification

A small scale Airline Company bought a new computer to computerize their airline ticket booking system. The company’s CEO asked to program the new system in C++ language.

Your job is to write a program to allocate seats for passengers for each flight. The company only has an airplane with capacity of ten seats. Your program should display an alternative menu below:

If a passenger chooses 1, your program should allocate seat in smoking area that is from seat 1 – 5.

On the other hand if the passenger chooses 2, give them seats in the nonsmoking area that is from seat 6 – 10.

Your program should also print a boarding pass for the passenger showing their seat number and indicating their selection of smoking/ nonsmoking area.

Your program cannot allocate a seat that has been booked by other passenger. And when the smoking area is fully booked, the passenger should be given an option to book a seat in the nonsmoking area and vise versa. If the passenger agrees with the option given, allocate them a seat; otherwise inform them the next flight schedule. "

our lecturer is asking us to submit Problem Analysis (state the problem, input, output requirements ). Any clue for me ?

Thank you .
grace be with you ...
xy

## All 13 Replies

hello..
i got the same question n waiting for the clue that can help my work...

tq,

i know how to do this..
but u must first attach ur work..
this is basic actually..

i know how to do this..
but u must first attach ur work..
this is basic actually..

oh , i see.. that why my post is no ppl answer so long time ...
Assumption: The user already choose the airplane location, which is the destination from A to B ,which is provide by the Airline Company .
Problem Analysis
• The purpose of the program is to allocate each seats for passengers for each flight on the certain date according the schedules provide by the Airline Company.
• For each airplane, it have capacity with ten seats. It divides to two type of seat , which is smoking area for seat 1 to 5, and non-smoking area which is 6 to 10.
• So, we need to design an algorithm to allocate the available seat for customer. If the type of seat which customer required is fully booked , we will give what kind of alternative solution .

Input/Output
The program will prompt user to input:
• Type of seat (smoking or non-smoking)
• User Detail
 Name
 IC number
 Passport number
 Date of Birth
 Email
 Phone
 Gender
 Occupation
 Nationality
 City
 Postal Code
 State
 Country
Output :
• Online Booking Reference
• Name
• Phone
• Seat Number
• Flight Details
 Departure Date
 Return Date
 Flight model
• Cabin class
• Type of seat areas (smoking or non-smoking)
• Fare (which is fixed ,since the location is fix)

Algorithm Design
If
The type of seat that customer required is available
End transcation
Else
The type of seat is not available
Else
Another type of seat
Else
Another flight

that is my first draft , thank you for your reply ...

your problem analysis seems not like ur question. ur question is very simple..
u no need to name, ic no etc..
just the smoke n non smoke..
understand ur question first pls
u can do like the problem analysis that u made, but its take time

make ur code first, then i'll check
but ur draft using if else is correct..u also can do it with array

``````# int seats[ 11 ]; // if you want to start counting from 1
# int smoking = 1; // where the seats for the Smoking-Category start
# int nonsmoking = 6; // where the seats for the Non-Smoking Category start
// initialize the seats[] to all zero if it is not already
# // If user wants the Smoking Category
#     // If there are more available seats for the smoking category
#               (in which bounds should the smoking variable be?)
#         // Notify the user about the reservation (user fprintf())
#         // Update the seats[] array (assign 1 to the taken seat)
#     // Else (no more seats)
#         // Notify the user that no more seats are available (use fprintf())
#         // Use your own strategy here... you can ask user if he wants a seat
#         // in the Non-Smoking Category
#     // EndIf
# // Else (the user wants the Non-Smoking Category)
#     // The same as above (except you use the nonsmoking variable instead
#     // of the smoking variable
# // EndIf``````

your problem analysis seems not like ur question. ur question is very simple..
u no need to name, ic no etc..
just the smoke n non smoke..
understand ur question first pls
u can do like the problem analysis that u made, but its take time

make ur code first, then i'll check
but ur draft using if else is correct..u also can do it with array

``````# int seats[ 11 ]; // if you want to start counting from 1
# int smoking = 1; // where the seats for the Smoking-Category start
# int nonsmoking = 6; // where the seats for the Non-Smoking Category start
// initialize the seats[] to all zero if it is not already
# // If user wants the Smoking Category
#     // If there are more available seats for the smoking category
#               (in which bounds should the smoking variable be?)
#         // Notify the user about the reservation (user fprintf())
#         // Update the seats[] array (assign 1 to the taken seat)
#     // Else (no more seats)
#         // Notify the user that no more seats are available (use fprintf())
#         // Use your own strategy here... you can ask user if he wants a seat
#         // in the Non-Smoking Category
#     // EndIf
# // Else (the user wants the Non-Smoking Category)
#     // The same as above (except you use the nonsmoking variable instead
#     // of the smoking variable
# // EndIf``````

#include <iostream>
#include <string>
using namespace std;

void initialize(int& flight, int& seatAreaOne, int& seatAreaTwo);
void plane(int flight);
void planeOne(int seatAreaOne);
void planeTwo(int seatAreaTwo);

int main()
{
string name;
string passport;
int flight;
int seatAreaOne;
int seatAreaTwo;
int seat[10]={1,2,3,4,5,6,7,8,9,10};

cout<<"WELCOME TO C++ AIRLINES."<<endl;
getline(cin, name);
cin>>passport;
cout<<"Name:"<<name<<endl;
cout<<"Passport number:"<<passport<<endl;

initialize(flight, seatAreaOne, seatAreaTwo);
plane(flight);

return main();

}
void initialize(int& flight, int& seatAreaOne, int& seatAreaTwo)
{
flight = 0;
seatAreaOne = 0;
seatAreaTwo = 0;

}

void plane(int flight)
{
int seatAreaOne;
int seatAreaTwo;
seatAreaOne = 0;
seatAreaTwo = 0;

cout<<"For your information, our company provides only two flights per day."<<endl;
cout<<"Enter (1) for flight A101 OR (2) for flight A102."<<endl;
cin>>flight;

if (flight==1)
{
cout<<"A101"<<endl;
planeOne(seatAreaOne);
for(seatnum=1,seatnum<6,seatnum++)
seat[seatnum]=seatnum;
}
else
{
cout<<"A102"<<endl;
planeTwo(seatAreaTwo);
for(seatnum=6,seatnum<11,seatnum++)
seat[seatnum]=seatnum
}

}
void planeOne(int seatAreaOne)
{
int seatArea;
cout<<"There are two types of seating area provided in this flight:"<<endl;
cout<<"Please choose a type of seating area."<<endl;
cout<<"Enter (1) for smoking area seat OR (2) for non-smoking area seat."<<endl;
cin>>seatArea;

if (seatArea == 1)
{
cout<<"Smoking area"<<endl;
}
else
{
cout<<"Non-smoking area"<<endl;
}
}
void planeTwo(int seatAreaTwo)
{
int seatArea;
cout<<"There are two types of seating area provided in this flight"<<endl;
cout<<"Please choose a type of seating area."<<endl;
cout<<"Enter (1) for smoking area seat OR (2) for non-smoking area seat."<<endl;
cin>>seatArea;

if (seatArea == 1)
{
cout<<"Smoking area"<<endl;
}
else
{
cout<<"Non-smoking area"<<endl;
}
}

``````#include <iostream>
#include <string>
using namespace std;

void initialize(int& flight, int& seatAreaOne, int& seatAreaTwo);
void plane(int flight);
void planeOne(int seatAreaOne);
void planeTwo(int seatAreaTwo);

int main()
{
string name;
string passport;
int flight;
int seatAreaOne;
int seatAreaTwo;
int seat[10]={1,2,3,4,5,6,7,8,9,10};

cout<<"WELCOME TO C++ AIRLINES."<<endl;
getline(cin, name);
cin>>passport;
cout<<"Name:"<<name<<endl;
cout<<"Passport number:"<<passport<<endl;

initialize(flight, seatAreaOne, seatAreaTwo);
plane(flight);

return main();

}
void initialize(int& flight, int& seatAreaOne, int& seatAreaTwo)
{
flight = 0;
seatAreaOne = 0;
seatAreaTwo = 0;

}

void plane(int flight)
{
int seatAreaOne;
int seatAreaTwo;
seatAreaOne = 0;
seatAreaTwo = 0;

cout<<"For your information, our company provides only two flights per day."<<endl;
cout<<"Enter (1) for flight A101 OR (2) for flight A102."<<endl;
cin>>flight;

if (flight==1)
{
cout<<"A101"<<endl;
planeOne(seatAreaOne);
for(seatnum=1,seatnum<6,seatnum++)
seat[seatnum]=seatnum;
}
else
{
cout<<"A102"<<endl;
planeTwo(seatAreaTwo);
for(seatnum=6,seatnum<11,seatnum++)
seat[seatnum]=seatnum
}

}
void planeOne(int seatAreaOne)
{
int seatArea;
cout<<"There are two types of seating area provided in this flight:"<<endl;
cout<<"Please choose a type of seating area."<<endl;
cout<<"Enter (1) for smoking area seat OR (2) for non-smoking area seat."<<endl;
cin>>seatArea;

if (seatArea == 1)
{
cout<<"Smoking area"<<endl;
}
else
{
cout<<"Non-smoking area"<<endl;
}
}
void planeTwo(int seatAreaTwo)
{
int seatArea;
cout<<"There are two types of seating area provided in this flight"<<endl;
cout<<"Please choose a type of seating area."<<endl;
cout<<"Enter (1) for smoking area seat OR (2) for non-smoking area seat."<<endl;
cin>>seatArea;

if (seatArea == 1)
{
cout<<"Smoking area"<<endl;
}
else
{
cout<<"Non-smoking area"<<endl;
}
}
``````

i ony able do until tis step , since i really dont know how to apply the array on tat
i understand wat u say
the question just request smoking o non smoking but the lecturer say need to include those things , i force to do that ..i dont know how to put the array inside my code

I have a small problem............... i want to know how to use randomise() function in C++. ?

also i want to know how to find output of this program

#include<iostream.h>
#include<stlib.h>
void main()
{
int guess;
randomize();
cin>>guess;
for(int i=1;i<=4;i++)
{ new = guess + random(i);
cout<<char(new);
}
}
If the user gives value of guess 65 then what could be the output from four option
1 ABBC
2 ACBA
3 BCDA
4 CABD

i ony able do until tis step , since i really dont know how to apply the array on tat
i understand wat u say
the question just request smoking o non smoking but the lecturer say need to include those things , i force to do that ..i dont know how to put the array inside my code

Here's a basic code; that's using two bool arrays to determinate if the seat is taken and if the seat is for smokers;

``````#include <iostream>

using namespace std;

#define Row 2
#define Column 10
bool SeatTaken [Row][Column];   // Is a specific seat taken?
bool SmokerSeat[Row][Column];   // Is a specific seat for smokers?

void ClearSeatsTaken()
{
for (int n=0; n<Column; n++)
for (int a=0; a<Row; a++)
SeatTaken [a][n]=0;
}

void SetSmokerSeats()
{
for (int n=0; n<Column; n++)
{for (int a=0; a<Row; a++)
{SmokerSeat [a][n]=0;}}
for (int n=0; n<Column/2; n++)
{for (int a=0; a<Row; a++)
{SmokerSeat [a][n]=1;}}
}

void TESTUNIT()
{
for (int n=0; n<Column; n++)
{for (int a=0; a<Row; a++)
{cout << SeatTaken [a][n] << " ";}
cout << endl;
}
}

void MISSING()
{
cout << "THIS PART OF THE PROGRAM IS MISSING; IT*S NOT MADE YET. IT SHOULD FIND ANOTHER RUTE IN THIS FUNCTION!" << endl;
}

void DedicateSeat(bool Smoker)
{
bool GlobalBreak=false;
for (int n=0; n<Column; n++)
{
if (GlobalBreak==true){break;}
for (int a=0; a<Row; a++)
{
if (GlobalBreak==true){break;}
if ((SmokerSeat [a][n]==Smoker) && (SeatTaken [a][n]==false))
{
SeatTaken [a][n]=true;
cout << "Seat" << a << " at " << n << " is now taken!" << endl;
GlobalBreak=true;
}
}
}
if (GlobalBreak==false)
{
bool Interrested=false;
cout << "ERROR! No ";
if (Smoker){cout << "smoker";}else{cout << "non smoker";}
cout << " seats avaiable!" << endl;
cout << "Interrested in another apparture? [Yes=1][No=0]" << endl;
cin >> Interrested;
if (Interrested){MISSING();}
}
}

bool YouASmoker()
{
int SmokerSeatNeeded=0;
cout << "Do you need a smokers seed? [Yes=1][No=0][Exit=-1]" << endl;
cin >> SmokerSeatNeeded;
if (SmokerSeatNeeded==-1){return 1;}
DedicateSeat(SmokerSeatNeeded);
return 0;
}

int main()
{
ClearSeatsTaken();
SetSmokerSeats();
while (1){
if(YouASmoker()==1){break;}
TESTUNIT();}
return 0;
}``````

^^It's just a simple test code; based upon a matrix array.
Hope it will help in any way

Here's a basic code; that's using two bool arrays to determinate if the seat is taken and if the seat is for smokers;

``````#include <iostream>

using namespace std;

#define Row 2
#define Column 10
bool SeatTaken [Row][Column];   // Is a specific seat taken?
bool SmokerSeat[Row][Column];   // Is a specific seat for smokers?

void ClearSeatsTaken()
{
for (int n=0; n<Column; n++)
for (int a=0; a<Row; a++)
SeatTaken [a][n]=0;
}

void SetSmokerSeats()
{
for (int n=0; n<Column; n++)
{for (int a=0; a<Row; a++)
{SmokerSeat [a][n]=0;}}
for (int n=0; n<Column/2; n++)
{for (int a=0; a<Row; a++)
{SmokerSeat [a][n]=1;}}
}

void TESTUNIT()
{
for (int n=0; n<Column; n++)
{for (int a=0; a<Row; a++)
{cout << SeatTaken [a][n] << " ";}
cout << endl;
}
}

void MISSING()
{
cout << "THIS PART OF THE PROGRAM IS MISSING; IT*S NOT MADE YET. IT SHOULD FIND ANOTHER RUTE IN THIS FUNCTION!" << endl;
}

void DedicateSeat(bool Smoker)
{
bool GlobalBreak=false;
for (int n=0; n<Column; n++)
{
if (GlobalBreak==true){break;}
for (int a=0; a<Row; a++)
{
if (GlobalBreak==true){break;}
if ((SmokerSeat [a][n]==Smoker) && (SeatTaken [a][n]==false))
{
SeatTaken [a][n]=true;
cout << "Seat" << a << " at " << n << " is now taken!" << endl;
GlobalBreak=true;
}
}
}
if (GlobalBreak==false)
{
bool Interrested=false;
cout << "ERROR! No ";
if (Smoker){cout << "smoker";}else{cout << "non smoker";}
cout << " seats avaiable!" << endl;
cout << "Interrested in another apparture? [Yes=1][No=0]" << endl;
cin >> Interrested;
if (Interrested){MISSING();}
}
}

bool YouASmoker()
{
int SmokerSeatNeeded=0;
cout << "Do you need a smokers seed? [Yes=1][No=0][Exit=-1]" << endl;
cin >> SmokerSeatNeeded;
if (SmokerSeatNeeded==-1){return 1;}
DedicateSeat(SmokerSeatNeeded);
return 0;
}

int main()
{
ClearSeatsTaken();
SetSmokerSeats();
while (1){
if(YouASmoker()==1){break;}
TESTUNIT();}
return 0;
}``````

^^It's just a simple test code; based upon a matrix array.
Hope it will help in any way

#include <iostream>
#include <string>
using namespace std;

void initialize(int& flight, int& seatAreaOne, int& seatAreaTwo);
void plane(int flight);
void planeOne(int seatAreaOne);
void planeTwo(int seatAreaTwo);
void ClearSeatsTaken();
void SetSmokerSeats();
void MISSING();
bool YouASmoker();
void TESTUNIT();

#define Row 1
#define Column 10
bool SeatTaken [Row][Column]; // Is a specific seat taken?
bool SmokerSeat[Row][Column]; // Is a specific seat for smokers?

int main()
{
string name;
string passport;
int flight;
int seatAreaOne;
int seatAreaTwo;
int n;

cout<<"WELCOME TO C++ AIRLINES."<<endl;
getline(cin, name);
cin>>passport;
cout<<"Name:"<<name<<endl;
cout<<"Passport number:"<<passport<<endl;

initialize(flight, seatAreaOne, seatAreaTwo);
plane(flight);
ClearSeatsTaken();
SetSmokerSeats();
while (1){
if(YouASmoker()==1){break;}
TESTUNIT();}

cout<<"Boardingpass slip"<<endl;
cout<<"Name:"<<name<<endl;
cout<<"Pasport number:"<<passport<<endl;

return 0;

}
void initialize(int& flight, int& seatAreaOne, int& seatAreaTwo)
{
flight = 0;
seatAreaOne = 0;
seatAreaTwo = 0;

}

void plane(int flight)
{
int seatAreaOne;
int seatAreaTwo;
seatAreaOne = 0;
seatAreaTwo = 0;

cout<<"For your information, our company provides only two flights per day."<<endl;
cout<<"Enter (1) for flight A101 OR (2) for flight A102."<<endl;
cin>>flight;

if (flight==1)
{
cout<<"A101"<<endl;
planeOne(seatAreaOne);
}
else
{
cout<<"A102"<<endl;
planeTwo(seatAreaTwo);
}

}
void planeOne(int seatAreaOne)
{

cout<<"There are two types of seating area provided in this flight:"<<endl;
bool YouASmoker();
}
void planeTwo(int seatAreaTwo)
{

cout<<"There are two types of seating area provided in this flight"<<endl;
cout<<"Please choose a type of seating area."<<endl;
bool YouASmoker();

}

void ClearSeatsTaken()
{
for (int n=0; n<Column; n++)
for (int a=0; a<Row; a++)
SeatTaken [a][n]=0;
}

void SetSmokerSeats()
{
for (int n=0; n<Column; n++)
{for (int a=0; a<Row; a++)
{SmokerSeat [a][n]=0;}}
for (int n=0; n<Column/2; n++)
{for (int a=0; a<Row; a++)
{SmokerSeat [a][n]=1;}}
}

void TESTUNIT()
{
for (int n=0; n<Column; n++)
{for (int a=0; a<Row; a++)
{cout << SeatTaken [a][n] << " ";}
cout << endl;
}
}

void MISSING()
{
cout << "THIS PART OF THE PROGRAM IS MISSING; IT*S NOT MADE YET. IT SHOULD FIND ANOTHER RUTE IN THIS FUNCTION!" << endl;
}

void DedicateSeat(bool Smoker)
{
bool GlobalBreak=false;
for (int n=0; n<Column; n++)
{
if (GlobalBreak==true){break;}
for (int a=0; a<Row; a++)
{
if (GlobalBreak==true){break;}
if ((SmokerSeat [a][n]==Smoker) && (SeatTaken [a][n]==false))
{

SeatTaken [a][n]=true;
cout << "Seat" << a << " at " << n << " is now taken!" << endl;

GlobalBreak=true;
}
}
}
if (GlobalBreak==false)
{
bool Interrested=false;
cout << "ERROR! No ";
if (Smoker){cout << "smoker";}else{cout << "non smoker";}
cout << " seats avaiable!" << endl;
cout << "Interrested in another apparture? [Yes=1][No=0]" << endl;
cin >> Interrested;
if (Interrested){MISSING();}
}
}

bool YouASmoker()
{
int SmokerSeatNeeded=0;
cout << "Do you need a smokers seed? [Yes=1][No=0][Exit=-1]" << endl;
cin >> SmokerSeatNeeded;
if (SmokerSeatNeeded==-1){return 1;}
DedicateSeat(SmokerSeatNeeded);
return 0;
}

Thanks for yr helping ... tis is my 2nd draft ..if i want to print a boardingpass, do i need to do another function call ?
my boarding pass include list out name, passport number , and the seat number ...

i m in trouble ladies and gentlemen agent help needed

i m in trouble ladies and gentlemen agent help needed

is that you have same prob with me ?

``````#include <iostream>
#include <string>
using namespace std;

void initialize(int& flight, int& seatAreaOne, int& seatAreaTwo);
void plane(int flight);
void planeOne(int seatAreaOne);
void planeTwo(int seatAreaTwo);
void ClearSeatsTaken();
void SetSmokerSeats();
void MISSING();
bool YouASmoker();
void TESTUNIT();

#define Row 1
#define Column 10
bool SeatTaken [Row][Column];   // Is a specific seat taken?
bool SmokerSeat[Row][Column];   // Is a specific seat for smokers?

int main()
{
string name;
string passport;
int flight;
int seatAreaOne;
int seatAreaTwo;
int n;

cout<<"WELCOME TO C++ AIRLINES."<<endl;
getline(cin, name);
cin>>passport;
cout<<"Name:"<<name<<endl;
cout<<"Passport number:"<<passport<<endl;

initialize(flight, seatAreaOne, seatAreaTwo);
plane(flight);
ClearSeatsTaken();
SetSmokerSeats();
while (1){
if(YouASmoker()==1){break;}
TESTUNIT();}

cout<<"Boardingpass slip"<<endl;
cout<<"Name:"<<name<<endl;
cout<<"Pasport number:"<<passport<<endl;

return 0;

}
void initialize(int& flight, int& seatAreaOne, int& seatAreaTwo)
{
flight = 0;
seatAreaOne = 0;
seatAreaTwo = 0;

}

void plane(int flight)
{
int seatAreaOne;
int seatAreaTwo;
seatAreaOne = 0;
seatAreaTwo = 0;

cout<<"For your information, our company provides only two flights per day."<<endl;
cout<<"Enter (1) for flight A101 OR (2) for flight A102."<<endl;
cin>>flight;

if (flight==1)
{
cout<<"A101"<<endl;
planeOne(seatAreaOne);
}
else
{
cout<<"A102"<<endl;
planeTwo(seatAreaTwo);
}

}
void planeOne(int seatAreaOne)
{

cout<<"There are two types of seating area provided in this flight:"<<endl;
bool YouASmoker();
}
void planeTwo(int seatAreaTwo)
{

cout<<"There are two types of seating area provided in this flight"<<endl;
cout<<"Please choose a type of seating area."<<endl;
bool YouASmoker();

}

void ClearSeatsTaken()
{
for (int n=0; n<Column; n++)
for (int a=0; a<Row; a++)
SeatTaken [a][n]=0;
}

void SetSmokerSeats()
{
for (int n=0; n<Column; n++)
{for (int a=0; a<Row; a++)
{SmokerSeat [a][n]=0;}}
for (int n=0; n<Column/2; n++)
{for (int a=0; a<Row; a++)
{SmokerSeat [a][n]=1;}}
}

void TESTUNIT()
{
for (int n=0; n<Column; n++)
{for (int a=0; a<Row; a++)
{cout << SeatTaken [a][n] << " ";}
cout << endl;
}
}

void MISSING()
{
cout << "THIS PART OF THE PROGRAM IS MISSING; IT*S NOT MADE YET. IT SHOULD FIND ANOTHER RUTE IN THIS FUNCTION!" << endl;
}

void DedicateSeat(bool Smoker)
{
bool GlobalBreak=false;
for (int n=0; n<Column; n++)
{
if (GlobalBreak==true){break;}
for (int a=0; a<Row; a++)
{
if (GlobalBreak==true){break;}
if ((SmokerSeat [a][n]==Smoker) && (SeatTaken [a][n]==false))
{

SeatTaken [a][n]=true;
cout << "Seat" << a << " at " << n << " is now taken!" << endl;

GlobalBreak=true;
}
}
}
if (GlobalBreak==false)
{
bool Interrested=false;
cout << "ERROR! No ";
if (Smoker){cout << "smoker";}else{cout << "non smoker";}
cout << " seats avaiable!" << endl;
cout << "Interrested in another apparture? [Yes=1][No=0]" << endl;
cin >> Interrested;
if (Interrested){MISSING();}
}
}

bool YouASmoker()
{
int SmokerSeatNeeded=0;
cout << "Do you need a smokers seed? [Yes=1][No=0][Exit=-1]" << endl;
cin >> SmokerSeatNeeded;
if (SmokerSeatNeeded==-1){return 1;}
DedicateSeat(SmokerSeatNeeded);
return 0;
}``````

Thanks for yr helping ... tis is my 2nd draft ..if i want to print a boardingpass, do i need to do another function call ?
my boarding pass include list out name, passport number , and the seat number ...

First of all, use CODEtags! Next up, if you want to print out the seat number, then you'll need to pass this be passed to somewhere, then written out, the simple solution would be to make a global var, and saving the seat number to this var, and calling that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.