Thank You

Pages: 123
I think the error is that the program enetered an infinite lop (before modification of line 105 above). Seems that
the program doesnt stop and wait for a user input the second time of the call to cin. Not clear to me why, but seems to be some issue
with mixing different types with cin.


http://www.cplusplus.com/forum/articles/6046/
closed account (1CohAqkS)
i still cant get the correct answer in case 3 plz help me plz plz.........
closed account (1CohAqkS)
in case 2 when i reserve a seat than it should display the passenger name.............i cant get that one plz help.....
Last edited on
closed account (zb0S216C)
i still cant get the correct answer in case 3 plz help me plz plz.........

What errors and/or warnings are your receiving( if any )? Telling us that case 3 isn't working isn't helpful. You need to provide us with the relevant information in order for others to give back useful advice.
closed account (1CohAqkS)
when i do case 3 it should ask me the name of the passenger u want to retrieve seat information and and display the name and the seat number the person has booked. plz help
closed account (1CohAqkS)
please help me................
if it isn't doing what you wanting.. think about your the statements you make here.

1
2
3
4
If case 3:
     Ask for a name // bet this is a cout with a following cin...
     look up the name // bet this looks like a loop searching a data storage system
     report the information gathered. // this looks like a cout with found info or error report 


Is your code doing this or not? Do you see the steps in your own code? Take a step back and look at the logic you are trying to accomplish first please.
closed account (1CohAqkS)
can any1 plz do my program as it is due 2moro and im rilly confused with it plz help me.........
Ask your teacher.....
closed account (1CohAqkS)
thnx 4 ur advise i'v dne tht already.....no use....
closed account (1CohAqkS)
plzzzzzzzzzzzzzzzzzzzzzzz any1 help me.......................
The proble is that all variables are newly initialzed during every loop.

Put that block
1
2
3
4
5
6
     string namez;
     int roww;
     int seat[13][5] = {0};
     int i,j,choice,num_of_seat,empty_seat=0,row,col;
     char name[20],column;
     char opselect,ticketType;
before 'do' and it should work.


perthi wrote:
but crashes if the name is a double name.
What do you mean by this?
What you wrote after 'default:' is incorrect since 4 is a valid option. 'exit()' should be the last resort and doesn't make sense here just let the user correct his fault instead of end the program
closed account (1CohAqkS)
thank you very much i have done that much can any1 plz tel me how to retrieve seat information of a person who has already booked a seat. for example: it should prompt the user enter the name of the passenger u want to retrieve the info? then it should display the seat number of that person...plzzz help with with this 1 this is the last case in ma program.....please help me........
Change int seat[13][5] = {0}; to string seat[13][5];

then
1
2
getData(namez, ticketType, row,col);
seat[row][col] = namez;
currently you don't change 'seat' at all!

instead of printf("\tx", seat[row][col]); which makes no sense since you always print x ->
1
2
3
4
if(seat[row][col].empty())
  printf("\t*");
else
  printf("\tx");



To show the information write something like:

1
2
3
4
5
6
7
8
9
10
11
void printBooked(const string &namez, int form[][5])
{
for(i = 0; i < 13; i++)
{
for(j = 0; j < 5; j++)
{
if(form[i][j] == namez)
  cout << 'A' + j << i; 
}
cout << endl;
}}
closed account (1CohAqkS)
this is the actual question.

Option 1
Displays aircraft seating plan.
Aircraft FJ531
A B C D E
Row 1 x x x x x
Row 2 x x x x x
Row 3 x x KRISHNILC x
Row 4 x x x x x
Row 5 x x x x x
Row 6 x x x x x
Row 7 x x x x x
Row 8 x x x x x
Row 9 BIMALAK x x x
Row 10 x x x x x
Row 11 x x x VIGNESHK
Row 12 x x x x x
Row 13 x x x x x


x – indicates seats that are empty.
Seats that are occupied passenger name and initials are given.


Option 2
Reserve a seat.

This should ask the user for:

Ticket type
FC - first class
EC - economy class

If the user selects FC it should only display first class seats i.e. from rows 1 to 4 from which the user can choose a seat.
Aircraft FJ531
A B C D E
Row 1 x x x x x
Row 2 x x x x x
Row 3 x x KRISHNILC x
Row 4 x x x x x




Desired Seat
The user has to give row number and seat to reserve a seat the program verifies that the seat is empty then only seat is reserved or else they are asked to select for another seat.

E.g.
User wants to reserve seat B in row 4.
Then he would have to enter. 4 B


Option 3
Retrieve seat information.
The user is asked for the name the seat is booked with and the seat information is displayed.

E.g.
Passenger Name: KRISHNILC
Your Seat information: 4 C


Option 4
Quit.
This option is used to terminate the program.




Hints:

1. You are required to create a two dimensional array of strings size 13 x 5 to store the seat information.
2. Use while loop to control the menu.
3. Use for loop to iterate array.
4. Implement necessary error handling.

please this is my last option as my teacher has given me two extra days to complete it. please help me. plz plz plz.
Last edited on
closed account (1CohAqkS)
please help me please please help me.
closed account (1CohAqkS)
please any1 help me plzzzzzzzzzzzzzzzzzzzzzzzzzz.
Hm, ok, you're following the good old 'programming by begging' approach

It's somewhat slower but my

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
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

void getData(string &namez, char& ticketType, string form[][5]);
void printForm(string form[][5], int from_row, int to_row);
void retrieveSeatInformation(string form[][5]);

struct flight_date 
{
  int day;
  int month;
  int year;
};

struct flight_time 
{
  int hour;
  int minute;
};

struct flight_information {
  char flight_num[4];
  struct flight_date date;
  struct flight_time time;
  char gate[2];
}  flight_info;


void
getData(string form[][5])
{
     int row;
     char column;
     string namez;
     char ticketType;
  cout << "The airplane has 13 rows, with six seats in each row. " << endl;
  cout << "Enter ticket type,\n"
       << "F for first class, \n"
       << "E for economy class:" << endl;
  cin >> ticketType;
  ticketType = static_cast<char>(toupper(ticketType));

  switch(ticketType)
    {
    case 'F':
      cout << "Row 1 and 4 are first class" << endl;
      printForm(form, 0, 3);
      break;
    case 'E':
      cout << "row 8 through 13 are economy class." << endl;
      printForm(form, 4, 13);
      break;
    }
  cout << "Enter the row number you want to sit: " << endl ;
  cin >> row;
  cout << "Enter the seat number (from A to E). " << endl;
  cin >> column;
  cout<< "enter passenger name:"<<endl;
  cin  >> namez;
  //getline(cin, namez); // could also work
  form[row - 1][static_cast<char>(toupper(column)) - 'A'] = namez;
cout << endl << endl;
}

void printForm(string form[][5], int from_row, int to_row)
{
int i, j;
cout << "* indicates that the seat is available; " << endl;
cout << setw(14) << "A" << setw(8) << "B" << setw(8) << "C"
<< setw(8) << "D" << setw(8) << "E"<< endl;
for(i = from_row; i < to_row; i++)
{
cout << left << setw(3) << "Row " << setw(2)<< i+1 ;
for(j = 0; j < 5; j++)
{
if(form[i][j].empty())
cout << right << setw(8) << "*";
else
cout << right << setw(8) <<form[i][j];
}
cout << endl;
}
cout << endl << endl;
}

void retrieveSeatInformation(string form[][5])
{
  int i, j;
     string namez;
  cout<< "enter passenger name:"<<endl;
  cin  >> namez;
for(i = 0; i < 13; i++)
{
for(j = 0; j < 5; j++)
{
if(form[i][j] == namez)
  cout << "Your Seat information: " << i + 1 << ' ' << static_cast<char>('A' + j); 
}
}
cout << endl << endl;
}


int main ()
{
int option = 0;
     string seat[13][5];

 do
   {
     cout<<"\t\tFJ513 Seat Reservation"<<endl;
     cout<<endl;
     cout<<"\t1.Display Aircraft Seating Plan"<<endl;
     cout<<"\t2.Reserve a Seat"<<endl;
     cout<<"\t3.Retrieve Seat Information"<<endl;
     cout<<"\t4.Quit"<<endl;
     cout<<endl;
     cout<<"enter your choice"<<endl;
     
     cin >> option;
     
     switch (option)
       {
       case 1:
         printForm(seat, 0, 13);
	 break;
       case 2:
	 getData(seat);
	 break;
       case 3:
	 retrieveSeatInformation(seat);
	 break;
       default:
	 if(option != 4)
	     cout<<"invalid choice"<< endl;
       }
   } while(option != 4);
 
 // system ("pause");
 return 0;
}
Wow, thanks coder.
I hate to condone cheating on schoolwork but that incessant, whiny pleading was starting to become painful. Hopefully that will be the end of it. Oh Please! Oh PLEASE, Oh PLLLLLEEEEAASSSSE!!! 8^D
BTW, nice code!
I hate to condone cheating on schoolwork but that incessant, whiny pleading was starting to become painful.


...Just ignore it?
Pages: 123