Jump to content
Sign in to follow this  
green_nirr

Airline Ticketing System

Recommended Posts

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) DISCOUNT

FIRST 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

Share this post


Link to post
Share on other sites

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 :D...

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...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...