How to write Problem analysis

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2009
Posts: 8
Reputation: xueyingkoo is an unknown quantity at this point 
Solved Threads: 0
xueyingkoo xueyingkoo is offline Offline
Newbie Poster

How to write Problem analysis

 
0
  #1
Oct 14th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 1
Reputation: adryna is an unknown quantity at this point 
Solved Threads: 0
adryna adryna is offline Offline
Newbie Poster
 
0
  #2
Oct 19th, 2009
hello..
i got the same question n waiting for the clue that can help my work...

tq,
adryna
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 2
Reputation: spiderweb_267 is an unknown quantity at this point 
Solved Threads: 0
spiderweb_267 spiderweb_267 is offline Offline
Newbie Poster

hye

 
0
  #3
20 Days Ago
i know how to do this..
but u must first attach ur work..
this is basic actually..
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 8
Reputation: xueyingkoo is an unknown quantity at this point 
Solved Threads: 0
xueyingkoo xueyingkoo is offline Offline
Newbie Poster

ohhh,, icc

 
0
  #4
20 Days Ago
Originally Posted by spiderweb_267 View Post
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
• 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 ...
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 2
Reputation: spiderweb_267 is an unknown quantity at this point 
Solved Threads: 0
spiderweb_267 spiderweb_267 is offline Offline
Newbie Poster
 
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
  1. # int seats[ 11 ]; // if you want to start counting from 1
  2. # int smoking = 1; // where the seats for the Smoking-Category start
  3. # int nonsmoking = 6; // where the seats for the Non-Smoking Category start
  4. // initialize the seats[] to all zero if it is not already
  5. # // If user wants the Smoking Category
  6. # // If there are more available seats for the smoking category
  7. # (in which bounds should the smoking variable be?)
  8. # // Notify the user about the reservation (user fprintf())
  9. # // Update the seats[] array (assign 1 to the taken seat)
  10. # // Else (no more seats)
  11. # // Notify the user that no more seats are available (use fprintf())
  12. # // Use your own strategy here... you can ask user if he wants a seat
  13. # // in the Non-Smoking Category
  14. # // EndIf
  15. # // Else (the user wants the Non-Smoking Category)
  16. # // The same as above (except you use the nonsmoking variable instead
  17. # // of the smoking variable
  18. # // EndIf
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 8
Reputation: xueyingkoo is an unknown quantity at this point 
Solved Threads: 0
xueyingkoo xueyingkoo is offline Offline
Newbie Poster
 
0
  #6
20 Days Ago
Originally Posted by spiderweb_267 View Post
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
  1. # int seats[ 11 ]; // if you want to start counting from 1
  2. # int smoking = 1; // where the seats for the Smoking-Category start
  3. # int nonsmoking = 6; // where the seats for the Non-Smoking Category start
  4. // initialize the seats[] to all zero if it is not already
  5. # // If user wants the Smoking Category
  6. # // If there are more available seats for the smoking category
  7. # (in which bounds should the smoking variable be?)
  8. # // Notify the user about the reservation (user fprintf())
  9. # // Update the seats[] array (assign 1 to the taken seat)
  10. # // Else (no more seats)
  11. # // Notify the user that no more seats are available (use fprintf())
  12. # // Use your own strategy here... you can ask user if he wants a seat
  13. # // in the Non-Smoking Category
  14. # // EndIf
  15. # // Else (the user wants the Non-Smoking Category)
  16. # // The same as above (except you use the nonsmoking variable instead
  17. # // of the smoking variable
  18. # // 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;
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;
}
}
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 8
Reputation: xueyingkoo is an unknown quantity at this point 
Solved Threads: 0
xueyingkoo xueyingkoo is offline Offline
Newbie Poster
 
0
  #7
20 Days Ago
Originally Posted by xueyingkoo View Post
#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
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 2
Reputation: aarpitgenius is an unknown quantity at this point 
Solved Threads: 0
aarpitgenius aarpitgenius is offline Offline
Newbie Poster
 
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
Last edited by aarpitgenius; 19 Days Ago at 1:09 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 52
Reputation: Skeen is an unknown quantity at this point 
Solved Threads: 1
Skeen's Avatar
Skeen Skeen is offline Offline
Junior Poster in Training
 
0
  #9
19 Days Ago
Originally Posted by xueyingkoo View Post
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;
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. #define Row 2
  6. #define Column 10
  7. bool SeatTaken [Row][Column]; // Is a specific seat taken?
  8. bool SmokerSeat[Row][Column]; // Is a specific seat for smokers?
  9.  
  10. void ClearSeatsTaken()
  11. {
  12. for (int n=0; n<Column; n++)
  13. for (int a=0; a<Row; a++)
  14. SeatTaken [a][n]=0;
  15. }
  16.  
  17. void SetSmokerSeats()
  18. {
  19. for (int n=0; n<Column; n++)
  20. {for (int a=0; a<Row; a++)
  21. {SmokerSeat [a][n]=0;}}
  22. for (int n=0; n<Column/2; n++)
  23. {for (int a=0; a<Row; a++)
  24. {SmokerSeat [a][n]=1;}}
  25. }
  26.  
  27. void TESTUNIT()
  28. {
  29. for (int n=0; n<Column; n++)
  30. {for (int a=0; a<Row; a++)
  31. {cout << SeatTaken [a][n] << " ";}
  32. cout << endl;
  33. }
  34. }
  35.  
  36. void MISSING()
  37. {
  38. cout << "THIS PART OF THE PROGRAM IS MISSING; IT*S NOT MADE YET. IT SHOULD FIND ANOTHER RUTE IN THIS FUNCTION!" << endl;
  39. }
  40.  
  41. void DedicateSeat(bool Smoker)
  42. {
  43. bool GlobalBreak=false;
  44. for (int n=0; n<Column; n++)
  45. {
  46. if (GlobalBreak==true){break;}
  47. for (int a=0; a<Row; a++)
  48. {
  49. if (GlobalBreak==true){break;}
  50. if ((SmokerSeat [a][n]==Smoker) && (SeatTaken [a][n]==false))
  51. {
  52. SeatTaken [a][n]=true;
  53. cout << "Seat" << a << " at " << n << " is now taken!" << endl;
  54. GlobalBreak=true;
  55. }
  56. }
  57. }
  58. if (GlobalBreak==false)
  59. {
  60. bool Interrested=false;
  61. cout << "ERROR! No ";
  62. if (Smoker){cout << "smoker";}else{cout << "non smoker";}
  63. cout << " seats avaiable!" << endl;
  64. cout << "Interrested in another apparture? [Yes=1][No=0]" << endl;
  65. cin >> Interrested;
  66. if (Interrested){MISSING();}
  67. }
  68. }
  69.  
  70. bool YouASmoker()
  71. {
  72. int SmokerSeatNeeded=0;
  73. cout << "Do you need a smokers seed? [Yes=1][No=0][Exit=-1]" << endl;
  74. cin >> SmokerSeatNeeded;
  75. if (SmokerSeatNeeded==-1){return 1;}
  76. DedicateSeat(SmokerSeatNeeded);
  77. return 0;
  78. }
  79.  
  80. int main()
  81. {
  82. ClearSeatsTaken();
  83. SetSmokerSeats();
  84. while (1){
  85. if(YouASmoker()==1){break;}
  86. TESTUNIT();}
  87. return 0;
  88. }
^^It's just a simple test code; based upon a matrix array.
Hope it will help in any way
Last edited by Skeen; 19 Days Ago at 2:28 pm.
// Skeen
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 52
Reputation: Skeen is an unknown quantity at this point 
Solved Threads: 1
Skeen's Avatar
Skeen Skeen is offline Offline
Junior Poster in Training
 
0
  #10
19 Days Ago
Originally Posted by aarpitgenius View Post
... I want to know how to use randomise() function in C++. ? ...
Try looking at this: http://www.cplusplus.com/reference/c.../cstdlib/rand/
Last edited by Skeen; 19 Days Ago at 2:31 pm.
// Skeen
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC