Thread: help i need the codes for this

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    4

    help i need the codes for this

    c i studied c for 1 month now and i want the codes for this program
    Last edited by gwendolyne; 11-15-2010 at 12:58 PM.

  2. #2
    Novice
    Join Date
    Jul 2009
    Posts
    568
    I think you will be failing this course.

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    4
    thnx for supporting

  4. #4
    C-no_Ob Bennie98's Avatar
    Join Date
    Oct 2010
    Location
    Ledeberg, Ghent, East-Flanders, Belgium
    Posts
    49
    it would be much easier to help you if you have a little bit of code to begin with...
    this forum isn't here to do your homework for you ^^

    C Board - Announcements in Forum : General Programming Boards

    but we can help if you are having problems somewhere...
    Because Tetris Is Unrealistic.

    "The fear of death is the most unjustified of all fears, for there's no risk of accident for someone who's dead." - Albert Einstein

    "The Edge... there is no honest way to explain it because the only people who really know where it is are the ones who have gone over." - Hunter S. Thompson

    "I never think of the future. It comes soon enough." - Albert Einstein

  5. #5
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    I think the least you could do is take this seriously and stop using "sms talk" to describe what you perceive to be a serious problem. You haven't even bothered to write proper English so I can imagine how much effort you are willing to put into getting your homework done.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  6. #6
    Registered User
    Join Date
    Nov 2010
    Posts
    4
    c i did some of it :
    Code:
    #include <stdio.h>
    #include <ctype.h>
    #include <conio.h>
    void mainmenu(void);
    void menu_PurchaseTicket(void);
    void menu_chooseTicket(void);
    void menu_BizClass(void);
    void menu_EconomyClass(void);
    void menu_DepartureBizKL(void);
    void menu_DepartureBizLK(void);
    void menu_DepartureEconKL(void);
    void menu_DepartureEconLK(void);
    void menu_ViewSeating(void);
    void menu_ChooseDestination(void);
    void menu_ChooseTime(void);
    void menu_ChooseSeat(void);
     
    int exit_ViewSeating, cust_TicketClass, cust_Destination, cust_Time, cust_Seat;
    char MenuSelect,TicketSelect,BizClassSelect,EconomyClassSelect,ViewSeatingSelect;
    main()
    {
    	mainmenu();
    }
     
    
    void mainmenu()
    {
    
    
    	printf("\n\t\t\t\t--WELCOME TO--");
    	printf("\n\t\t<<<< AIRLINE RESERVATION SYSTEM >>>> \n");
     
    	printf("\n\n\t\t\t\t%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
    	printf("\n\t\t\t\t%%%%%% Main Menu %%%%%%%\n");
    	printf("\t\t\t\t%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n");
     
     
     
    	printf("\n\t\t\t\tP to Purchase Ticket\n");
    	printf("\n\t\t\t\tV to View Seating Arrangement\n");
    	printf("\n\t\t\t\tQ to Quit the system\n\n");
    	printf("\n\n\t\t\t\tPlease enter your choice:");
    	fflush(stdin);
    	MenuSelect = getchar();
     
    	switch(MenuSelect)
    	{
     
    		case 'P':
    		case 'p':
    			menu_PurchaseTicket();
    			break;
     
     
    		case 'V':
    		case 'v':
     
    			menu_ViewSeating();
    			break;
     
     
    		case 'Q':
    		case 'q':
     
    			printf("Thank you for choosing Airlines Reservation System");
    			break;
     
     
    		default:
    			printf("Please enter the correct selection");
     
     
    	}
     
    }
     
    void menu_PurchaseTicket()
    {
    	menu_chooseTicket();
    	menu_ChooseDestination();
    	menu_ChooseTime();
    	menu_ViewSeating();
    	menu_ChooseSeat();
     
    	int seat[cust_TicketClass][cust_Destination][cust_Time][cust_Seat];
    	int a,b,c,d;
    	for(a=0;a<2;a++)
    	{
    		if(cust_TicketClass == 0)
    			printf("Business Class");
    		else
    			printf("Economy Class");
     
    		for(b=0;b<2;b++)
    		{
    			if(cust_Destination == 0)
    				printf("Destination: Kuala Lumpur --> Langkawi\n\n");
    			else
    				printf("Destination: Langkawi --> Kuala Lumpur\n\n");
     
    			for(c=0;c<5;c++)
    			{
    				switch(cust_Time)
    				{
    					case '1':
    						printf("Departure Time: 9.00 a.m\n");
     
    					case '2':
    						printf("Departure Time: 11.00 a.m\n");
     
    					case '3':
    						printf("Departure Time: 1.00 p.m\n");
     
    					case '4':
    						printf("Departure Time: 3.00 p.m\n");
     
    					case '5':
    						printf("Departure Time: 5.00 p.m\n");
     
    					default:
    						printf("Please enter the correct selection\n\n");
     
    					for(d=0;d<25;d++)
    					{
    						if(cust_Seat>25 || cust_Seat<0)
    							printf("Invalid Seat Number");
     
    						if(cust_Seat>0 || cust_Seat<25)
    							seat[cust_TicketClass][cust_Destination][cust_Time][cust_Seat]=1;
    					}
    				}
    			}
    		}
    	}
     
     
    }
     
    void menu_chooseTicket()
    {
    
    	printf("Please choose your Tciket Class\n\n");
    	printf("1 >> Business Class\n\n");
    	printf("2 >> Economy Class\n\n");
    	printf("Please enter your selection --> ");
    	fflush(stdin);
    	scanf("%d",&cust_TicketClass);
     
    }
     
    void menu_ChooseDestination()
    {
    
    	printf("Please choose destination\n\n");
    	printf("1 >> Kuala Lumpur --> Langkawi\n\n");
    	printf("2 >> Langkawi --> Kuala Lumpur\n\n");
    	printf("Please enter your selection --> ");
    	fflush(stdin);
    	scanf("%d",&cust_Destination);
    }
     
    void menu_ChooseTime()
    {
    
    	printf("Please choose flight time\n\n");
    	printf("1 >> 9  a.m.\n\n");
    	printf("2 >> 11 a.m.\n\n");
    	printf("3 >> 1  p.m.\n\n");
    	printf("4 >> 3  p.m.\n\n");
    	printf("5 >> 5  p.m.\n\n");
    	printf("Please enter your selection --> ");
    	fflush(stdin);
    	scanf("%d",&cust_Time);
    }
     
    void menu_ChooseSeat()
    {
    	printf("Please choose your seat --> ");
    	scanf("%d",&cust_Seat);
     
    }
     
     
    void menu_BizClass()
    {
    
    	printf("Destination Menu\n");
    	printf("A --> Kuala Lumpur to Langkawi\n");
    	printf("B --> Langkawi to Kuala Lumpur\n");
    	printf("M --> Return to Main Menu\n");
    	printf("Please Enter your Selection -->");
    	fflush(stdin);
    	BizClassSelect = getchar();
     
    	switch(BizClassSelect)
    	{
    		case 'a':
    		case 'A':
    			menu_DepartureBizKL();
    			break;
     
    		case 'b':
    		case 'B':
    			menu_DepartureBizLK();
    			break;
     
    		case 'M':
    		case 'm':
    			mainmenu();
    			break;
     
    		default:
    
    			printf("Please enter the correct selection");
    			menu_BizClass();
    	}
     
     
     
    }
     
    void menu_EconomyClass()
    {
    
    	printf("Destination Menu\n");
    	printf("A --> Kuala Lumpur to Langkawi\n");
    	printf("B --> Langkawi to Kuala Lumpur\n");
    	printf("M --> Return to Main Menu\n");
    	printf("Please Enter your Selection -->");
    	fflush(stdin);
    	EconomyClassSelect = getchar();
     
    	switch(EconomyClassSelect)
    	{
    		case 'a':
    		case 'A':
    			menu_DepartureEconKL();
    			break;
     
    		case 'b':
    		case 'B':
    			menu_DepartureEconLK();
    			break;
     
    		case 'M':
    		case 'm':
    			mainmenu();
    			break;
     
    		default:
    
    			printf("Please enter the correct selection");
    			menu_EconomyClass();
    	}
    }
     
    void menu_DepartureBizKL()
    {
    
    	printf("Business Class\n");
    	printf("Departure Menu\n");
    	printf("Destination: Kuala Lumpur --> Langkawi\n");
    	printf("A --> 9.00  a.m\n");
    	printf("B --> 11.00 a.m\n");
    	printf("C --> 1.00  p.m\n");
    	printf("D --> 3.00  p.m\n");
    	printf("E --> 5.00  p.m\n");
    	printf("Please enter your selection --> ");
     
     
    }
     
    void menu_DepartureBizLK()
    {
    
    	printf("Business Class\n");
    	printf("Departure Menu\n");
    	printf("Destination: Langkawi --> Kuala Lumpur\n");
    	printf("A --> 9.00  a.m\n");
    	printf("B --> 11.00 a.m\n");
    	printf("C --> 1.00  p.m\n");
    	printf("D --> 3.00  p.m\n");
    	printf("E --> 5.00  p.m\n");
    	printf("Please enter your selection --> ");
     
     
    }
     
    void menu_DepartureEconKL()
    {
    
    	printf("Economy Class\n");
    	printf("Departure Menu\n");
    	printf("Destination: Kuala Lumpur --> Langkawi\n");
    	printf("A --> 9.00  a.m\n");
    	printf("B --> 11.00 a.m\n");
    	printf("C --> 1.00  p.m\n");
    	printf("D --> 3.00  p.m\n");
    	printf("E --> 5.00  p.m\n");
    	printf("Please enter your selection --> ");
     
     
    }
     
    void menu_DepartureEconLK()
    {
    
    	printf("Economy Class\n");
    	printf("Departure Menu\n");
    	printf("Destination: Langkawi --> Kuala Lumpur\n");
    	printf("A --> 9.00  a.m\n");
    	printf("B --> 11.00 a.m\n");
    	printf("C --> 1.00  p.m\n");
    	printf("D --> 3.00  p.m\n");
    	printf("E --> 5.00  p.m\n");
    	printf("Please enter your selection --> ");
     
     
    }
     
    void menu_ViewSeating()
    {
    	int row,col;
    	int seats[5][5]={0};
    	printf("\t\tSeating In All Flights\n\n");
    	printf("\t1\t2\t3\t4\t5\n");
    		for (row=0; row<5; row++)
    		{
    			printf("\n%d", row+1);
    			for (col=0; col<5; col++)
    			{
    				printf("\t%d", seats[row][col]);
    			}
    		}
     
     
    	printf("\n\nBusiness Class Seats: 11,12,13,14,15\n\n");
    	printf("\n\nEconomy Class Seats: Other than the above\n\n");
    }
    and here wat we should do :

    )to book
    2)to cancel
    3)view data
    4)quit
    so when the user press 1 it should go for booking when it go for booking the it should allow the user to choose destination from four destination and the charge of every destination should be written then they should choose if it is one way or 2 ways then choose the day time and then choose how many passenger and how many of them are adult children infant then allow them to enter them name age passport number and then display the charge for the tickets if there is any adult then 100% of the charge children 60% and infant 10%.but if the user entered 2 then it should go for cancellation so the user after he enter his passport number should be allowed to cancel his booking with a full charge back but if the cancellation were at the same time then only 60% of the charge and for view data after the user enter his passport number they should display the whole data of the booking. i have no idea how to do this and the teacher didnt tell us how to do it he want us to read and learn so plz ireally need ur help
    Last edited by gwendolyne; 11-15-2010 at 12:50 PM.

  7. #7
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    And no code tags! Thanks for making that highly unreadable. Please, for the love of all things good and holy, read the forum policies, entitled "Read before posting": C Board - Announcements in Forum : C Programming. Pretty much every forum has a "sticky" post like this, at the top of the forum, and following the rules will ensure you get the help you need.

    Now, edit your post to use code tags, and make sure your code is properly formatted/indented. Then you might find us a bit more sympathetic to your needs.

  8. #8
    Registered User
    Join Date
    Nov 2010
    Posts
    4
    sorry i dint no that i have to tag the codes

  9. #9
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    c i did some of it :
    No, you did NONE of it, liar!

  10. #10
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by gwendolyne View Post
    c i did some of it :
    ...
    plz ireally need ur help
    What did claudiu say about SMS talk in post #5?

    so when the user press 1 it should go for booking when it go for booking the it should allow the user to choose destination from four destination and the charge of every destination should be written then they should choose if it is one way or 2 ways then choose the day time and then choose how many passenger and how many of them are adult children infant then allow them to enter them name age passport number and then display the charge for the tickets if there is any adult then 100% of the charge children 60% and infant 10%.but if the user entered 2 then it should go for cancellation so the user after he enter his passport number should be allowed to cancel his booking with a full charge back but if the cancellation were at the same time then only 60% of the charge and for view data after the user enter his passport number they should display the whole data of the booking.
    Those are the two longest run-on sentences I have ever seen, and not a speck of punctuation or capitalization. Read up on how to ask questions the smart way. There is a link to it on the "Read before posting" page I linked to in my previous post (#7).

    i have no idea how to do this and the teacher didnt tell us how to do it he want us to read and learn so
    So why aren't you reading and learning?

    )to book
    2)to cancel
    3)view data
    4)quit
    Are you sure you wrote the program you posted? This doesn't match the menu your code produces. You use letters, and don't have a "cancel" option.

    I don't think anybody wants to help you plagiarize and cheat your way though a course.

  11. #11
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Quote Originally Posted by anduril462 View Post
    I don't think anybody wants to help you plagiarize and cheat your way though a course.
    And for good reason too. Then you will end up being our coworker one day.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  12. #12
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Are you sure you wrote the program you posted? This doesn't match the menu your code produces. You use letters, and don't have a "cancel" option.
    As I demonstrated in my link, the OP did NOT write the code, it was found.

  13. #13
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by rags_to_riches View Post
    As I demonstrated in my link, the OP did NOT write the code, it was found.
    Sorry, I was composing my message when you found and posted that, which I saw once I submitted my reply. I was quite certain the OP didn't write it, but thought it too presumptuous a claim without any evidence, hence the suggestive question.

  14. #14
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    I figured as much

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. codes
    By IfYouSaySo in forum A Brief History of Cprogramming.com
    Replies: 34
    Last Post: 11-18-2005, 03:09 PM
  2. action replay codes
    By c++.prog.newbie in forum Game Programming
    Replies: 2
    Last Post: 02-28-2004, 08:47 AM
  3. converting scan codes to ascii codes
    By stupid_mutt in forum C Programming
    Replies: 11
    Last Post: 01-25-2002, 04:06 PM