| | |
How to write Problem analysis
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2009
Posts: 8
Reputation:
Solved Threads: 0
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:
Please type 1 for “smoking”
Please type 2 for “nonsmoking”
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
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:
Please type 1 for “smoking”
Please type 2 for “nonsmoking”
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
•
•
Join Date: Aug 2009
Posts: 8
Reputation:
Solved Threads: 0
•
•
•
•
i know how to do this..
but u must first attach ur work..
this is basic actually..
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
Phone
Gender
Occupation
Nationality
• Address Detail
Address
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 ...
•
•
Join Date: Nov 2009
Posts: 2
Reputation:
Solved Threads: 0
0
#5 20 Days Ago
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
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
C++ Syntax (Toggle Plain Text)
# 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
•
•
Join Date: Aug 2009
Posts: 8
Reputation:
Solved Threads: 0
0
#6 20 Days Ago
•
•
•
•
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
C++ Syntax (Toggle Plain Text)
# 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 <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;
cout<<"Please enter your name:"<<endl;
getline(cin, name);
cout<<"Please enter your passport number:"<<endl;
cin>>passport;
cout<<"Name:"<<name<<endl;
cout<<"Passport number:"<<passport<<endl;
initialize(flight, seatAreaOne, seatAreaTwo);
plane(flight);
cout<<"your seat number is "<<seatnum<<endl;
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;
}
}
•
•
Join Date: Aug 2009
Posts: 8
Reputation:
Solved Threads: 0
0
#7 20 Days Ago
•
•
•
•
#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;
cout<<"Please enter your name:"<<endl;
getline(cin, name);
cout<<"Please enter your passport number:"<<endl;
cin>>passport;
cout<<"Name:"<<name<<endl;
cout<<"Passport number:"<<passport<<endl;
initialize(flight, seatAreaOne, seatAreaTwo);
plane(flight);
cout<<"your seat number is "<<seatnum<<endl;
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
•
•
Join Date: Nov 2009
Posts: 2
Reputation:
Solved Threads: 0
0
#8 19 Days Ago
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
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
Last edited by aarpitgenius; 19 Days Ago at 1:09 pm.
0
#9 19 Days Ago
•
•
•
•
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
C++ Syntax (Toggle Plain Text)
#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; }
Hope it will help in any way
Last edited by Skeen; 19 Days Ago at 2:28 pm.
// Skeen
0
#10 19 Days Ago
•
•
•
•
... I want to know how to use randomise() function in C++. ? ...
Last edited by Skeen; 19 Days Ago at 2:31 pm.
// Skeen
![]() |
Similar Threads
- Weird file.write problem. (Python)
- I have problem about Knapsack in ASM (Assembly)
- vb.net NEWBIE!! Triangle problem!! (VB.NET)
- pascal write problem (ASP.NET)
- CDRW Problem (USB Devices and other Peripherals)
- XP crashes on any dialup connection (wanarp.sys / tcpip.sys problem) (Windows NT / 2000 / XP)
- do while; if else? am I using the right code for the problem? (C++)
Other Threads in the C++ Forum
- Previous Thread: Talks on Data Mining
- Next Thread: MySQL, C++ connection
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





