green_nirr 0 Report post Posted September 20, 2008 Salam sejahtera..saya ahli baru dan bermasalah sket dalam nak bangunkan C untuk sistem tiket airline.PROBLEM:You are required to design an airline ticketing system using C language.Assume that your airline has only 1 plane, with only 10 seats.Your system should entertain user’s requests to by the airline tickets. The airplane is divided into 2 sections.CLASS TYPE SEAT NO. PRICE(per seat) DISCOUNTFIRST CLASS 1-5 RM120 Gold Citizen-25%Children(below 7)-50%ECONOMY CLASS 6-10 RM90 Gold Citizen-10%Children(below 7)-20%Let the user decide whether they want to choose first class or economy class. The system should be able to allocate seats, as well as displaying message seat are taken (if applicable). Each customer may have the flexibility to choose seats that is still available.The system will capture the customer’s information such as first name, last name, age, gender, and mailing address. Then the system will calculate the total price a customer needs to pay after they have confirmed their order.Lastly, the system will recap the order information before the application ended. You can do this using your own creativity.THINGS TO IGNORE:Due to time constraints, you will not going to design a full blown airline ticketing system.Therefore, assume that your system will only sell tickets for one journey date only.Therefore, avoid the confusions of making reservation for multiple journey dates, one way or return trips, etc.Ini adalah coding yang dok tak jalan2 lagik...#include <stdio.h>#include <time.h>void details (char fname[], int age[]);void reservation(int seat[]);double discount (int age[], int seat[]);int main(){ double price; char fname[30]; int age[10], seat[10]; time_t rawtime; time (&rawtime); printf("%s",ctime (&rawtime)); puts("\n"); puts("\t\t'WELCOME TO CFS IIUM AIRLINE TICKETING SYSTEM'"); puts("\n"); puts("\t****************************************************************"); printf("\tCLASS TYPE\tSEAT NO.\tPRICE(per seat)\t\tDISCOUNT\t\t"); puts("****************************************************************"); puts("\tFIRST CLASS\t01-05\t\tRM120\t\tGold Citizen-25%"); puts("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tChildren(<7)-50%"); puts("\t****************************************************************"); puts("\tECONOMY CLASS\t06-10\t\tRM90\t\tGold Citizen-10%"); puts("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tChildren(<7)-20%"); puts("\t****************************************************************"); puts("\n"); puts("\n"); details (fname,age); reservation (seat); price = discount (seat,age); return 0; } void details (char fname[], int age[]){ char name[40], email[40], gender; printf("Your name: "); scanf("%s",name); printf("\nAge: "); scanf("%d",&age); printf("\nGender (F/M): "); scanf("%c",&gender); printf("\nE-mail address: "); scanf("%s",email); return;}void reservation(int seat[]){ int f, e, s; printf("Choose your seat no: "); for (s=0;s<10;s++) { scanf("%d",&seat[0]); if (seat[0]>=1 && seat[0]<=5) { printf("You are in first class\n"); f = seat[0]; } else if (seat[0]>=6 && seat[0]<=10) { printf("You are in economy class\n"); e = seat[0]; } else printf("Invalid seat no\n"); } return;}double discount (int age[], int seat[]){ double price; switch (seat[0]) { case 'f' : if(age[0] >= 60) { price = (25/100)*120; printf("The price for the seat is RM%.2f",price); } else if(age[0] <= 7) { price = (50/100)*120; printf("The price for the seat is RM%.2f",price); } else printf("The price for the seat is RM120"); break; case 'e' : if(age[0] >= 60) { price = (10/100)*90; printf("The price for the seat is RM%.2f",price); } else if(age[0] <= 7) { price = (20/100)*120; printf("The price for the seat is RM%.2f",price); } else printf("The price for the seat is RM90"); break; default : ; break; } return price; }p/s - please if ada sesape dapat tolong... thank you Quote Share this post Link to post Share on other sites
ahaksz! 44 Report post Posted September 20, 2008 esemen ke nie bro? Quote Share this post Link to post Share on other sites
betik 11 Report post Posted October 8, 2008 apa yang tak jalan?...apa error dia?apsal age dan seat perlu dijadikan sebagai array sedangkan nama customer cuma 1(c0de guna char array, bukan array untuk nama customer mengikut jumlah customer yang menempah)...printf("Your name: ");scanf("%s",name);code ni bahya skit sebab scanf cuma simpan string sebelum white space atau ENTER...biasanya, nama akan ada space, so xleh guna scanf...guna "gets(nama)"...dan scanf yang selepas tu(utk dapatkan umur), akan menyebabkan "scanf("%c",&gender)" akan menyimpan ascci value utk ENTER...cara mudah, tmbh "getchar()" slps dptkan umur...erm....dan byk lagi ...tak larat nak baca c0de ko sbb x diwrap dlm code tag ...kalu nak ikut soklan, macam kena ingat seat apa yg dah ditempah...so kena simpan data tu...bole guna struct atopon simpan data2 customer yang dah menempah dalam text file, etc... Quote Share this post Link to post Share on other sites