Thread: airline reserve system

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    16

    airline reserve system

    I am trying to write a airline reserve system like program, I have to write a program to assign seats on each flights (10 max for each flight)

    u ask the user to type either 1 or 2, 1 for 1st class and 2 for coach.
    seats 1-5 is first class and 6-10 is coach, then after they input the type the programs prints out the passengers seat and whether its 1st class or coach.

    when 1st class is full, the program should ask if the passenger wants coach or wait for next flight and vise versa. if they want next flight print out next flight leaves in 3 hours.

    Code:
    #include <stdio.h>
    
    int main()
    {
    	int seats [9],i,type,choice,first=0,econ=5;
    
    	printf("Please type 1 for \"first class\"\n");
    	printf("Please type 2 for \"economy\"\n");
    	scanf("%d", &type);
    
    for(i=0; i<9; i++)
    {
    	if(type == 1) {
    		seats[first]=0;
    		printf("your seat number is %d, first class\n");
    		first++;
    	}
    	if (type == 2) {
    		seats[econ]=5
    		printf("Your seat number is %d, economy class\n");
    		econ++;
    	}
    	printf("Please type 1 for \"first class\"\n");
    	printf("Please type 2 for \"economy\"\n");
    	scanf("%d", &type);
    	}
    
    for(i=0; i<9; i++)
    	if (first == 4) {
    		printf("Type 2 for economy seat or 3 for another flight\n");
    		scanf("%d",&choice);
    
    	else if (econ ==9) {
    		printf("Type 1 for first class seat or 3 for another flight\n");
    		scanf("%d",&choice);
    	}
    	if (choice ==3) {
    		printf("Next flight leaves in 3 hours\n");
    	}
    return 0;
    }
    I try to write the program but it wont even run for some reason

  2. #2
    Chief Code Coloniser!
    Join Date
    Apr 2005
    Posts
    121
    First of all you need to make sure that you're closing all your scopes ...you'll find that there's a closing bracket (ie. '}' )missing!!

    Secondly terminate the statement "seats[econ]=5" with a semicolon.

    That should at least get things to compile... then give it another spin and see how you go

  3. #3
    Registered User
    Join Date
    Dec 2004
    Posts
    12
    Do u have an algorithm in place ?

    Put the menu in a function with one more menu-item = exit. The function should return the value checked, that is, 1 if they want a first class, 2 if they want a coach class, and 3 if they want to exit the program. This way, u can put the validation code for the input in the menu function itself. Every program should have an entry and exit point.

    And moreover, don't make the number of total seats as the check, use whether there are any seats left as check..

    Have u decided on the flow of the program ?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File System Implementation
    By dodgeviper in forum C Programming
    Replies: 9
    Last Post: 11-16-2007, 01:04 PM
  2. Using system icons
    By @nthony in forum Windows Programming
    Replies: 1
    Last Post: 01-13-2007, 07:56 PM
  3. Linux database system needed
    By BobS0327 in forum Tech Board
    Replies: 7
    Last Post: 06-11-2006, 03:56 PM
  4. measuring system resources used by a function
    By Aran in forum C Programming
    Replies: 1
    Last Post: 03-13-2006, 05:35 PM
  5. BIOS system and memory allocation problem
    By beely in forum Tech Board
    Replies: 9
    Last Post: 11-25-2003, 07:12 AM