Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > C++

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 12-17-2004, 04:03 PM
Carcophan Carcophan is offline
Registered User
 
Join Date: Nov 2004
Posts: 12
Airline seating problem

I am sure many of you have seen the 'Airline seating reservation' assignment that C++ classes give out. I would like to state that I am NOT asking people to do it for me, although I am having a problem getting it to work properly and would greatly appreciate some help.

For those of you who don't know the assignment is... "A small airline company has one 10 seat plane and needs a reservation system. The program should use a menu display to decide if the customer wants economy or first class seating (1-5 for FC, 6-10 for eco). The program needs to print a boarding pass with the assigned section and seat in it. Use a single-subscripted array to represent the seating chart and initialize each seat to 0 to indicate that the seat is empty. Program shouldnt assign a seat that is taken blah blah...but when a section is full the program should ask if a seat in the opposing section is okay and assign that, if they choose no or both sections are full the program should suggest taking the next flight."

That said...my problem is:
I can get the program to recognize that the first class section is full when it gets full and it promts the user to either take a economy seat or take the next flight. BUT when the economy section is full it doesnt suggest First class or the next flight. It does stop counting seats at 10, but once at 10 it just keeps asking if I would like to reserve another FC seat econo seat or -1 to end. The code for both first class and econmy should pretty much be the same and I simple can not see why it doesnt work right.

I'm not sure if i should post all the code here, incase other students are here, I dont want to do there project for them, but I would be more then happy to email it to you. Any help would be appreciated and it is due monday so i'm in a bit of a bind.

Thanks.
Reply With Quote
  #2  
Old 12-17-2004, 06:32 PM
jonnin jonnin is offline
Senior Member
 
Join Date: Dec 2003
Posts: 3,008
Your problem is probably a slightly bad logic error; for example you may have it test if fc is full, and if so do whatever, and then your test for the if normal is full is accidentally inside the first class one or something. Its a simple logic error and the only way to find it is to debug it. First pass is to look for

if(somthing); <--- oops! ; makes a problem!
or messed up brackets


Debugging can be done with the build in debugger (add watches to all variables and step in it)
or by printing the thing and playing computer (not too useful on larger projects, but it can help)
or adding print statements of this form:
cout << "I got here #1 "<< write any important value etc;
Reply With Quote
  #3  
Old 12-17-2004, 07:37 PM
Carcophan Carcophan is offline
Registered User
 
Join Date: Nov 2004
Posts: 12
I figured it out :rolleyes:

I had 2 while loops, on with while(i < 10) and while(j <10)...both should have been i becuase both while loops were using the same 10 elements.

And printing it actually helped me notice that, thanks jonnin.
Reply With Quote
  #4  
Old 12-18-2004, 01:07 AM
jonnin jonnin is offline
Senior Member
 
Join Date: Dec 2003
Posts: 3,008
no problem =)
Someone asked why I don't like the i j notation, and one of the reasons is both are dotted sticks, some fonts are far to close for comfort. I hate slavery to convention... take u v subs in calculus... most math professors can't write u and v distinctly, but they refuse to make it like P and M or something you can tell apart, because its always been u and v. *shakes his fist*
I feel better now...
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 02:52 AM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.