#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#include<string.h>
#define name 20
struct detail
{
int iway;
int oneway;
int twoway;
int age;
int id;
int id2;
char cname[name];
char date[10];
char date1[10];
char itime[10];
char itime2[10];
};
struct place
{
int idestination;
char jb[30];
char pen[30];
char ter[30];
char lg[30];
};
void main()
{
void booking(),check(),display(),cancel(),save();
struct detail sdetail;
struct place splace;
char user,pass;
char choice;
printf("Enter username: ");
scanf(" %s",&user);
printf("\nEnter password:");
scanf(" %s",&pass);
system("cls");
do
{
printf("\n\n\t\t ********************************************************************");
printf("\n\t\t WELCOME TO DINS AIRLINES ");
printf("\n\t\t *******************************************************************");
printf("\n\n\n\t\t Please enter your choice from below (1-5):");
printf("\n\n\t\t 1. Booking");
printf("\n\n\t\t 2. Check Schedule");
printf("\n\n\t\t 3. DISPLAY RECORDS");
printf("\n\n\t\t 4. Cancel");
printf("\n\n\t\t 5. EXIT");
printf("\n\n\t\t Enter your choose ");
scanf("%d", &choice); fflush(stdin);
system("cls");
switch (choice) {
case 1:
booking();
break;
case 2:
check();
break;
case 3:
display();
break;
case 4:
cancel();
break;
case 5:
{
save();
break;
}
Default:
printf("\n\n\t SORRY INVALID CHOICE!");
printf("\n\n\t PLEASE CHOOSE FROM 1-5");
}
getch();
} while (choice != 5);
}
void booking()
{
struct detail sdetail;
struct place splace;
char user,pass,key;
int choose,ticket;
char proceed,choice,meals;
int c,p,a,sum=0;
int i;
int j;
int s[40]={};
float pay=0,total_price;
printf("1.KL - JOHOR BHARU\t\t\t\t 0830-0930\t 1400-1500\n");
printf("2.KL - PENANG\t\t\t\t\t 0800-0900\t 1300-1400 \n");
printf("3.KL - TERENGGANU\t\t\t\t 1000-1120\t 1700-1820 \n");
printf("4.KL - LANGKAWI \t\t\t\t 0900-1015\t 1600-1715 ");
printf("\nHow many ticket did you want? ");
scanf("%d",&ticket);
for(a=1;a<=ticket;a++){
printf("\n---------------------BOOKING TICKET----------------------\n");
printf("NAME: ");
scanf(" %s",&sdetail.cname);
strupr(sdetail.cname);
printf("AGE: ");
scanf(" %d",&sdetail.age);
printf("PASSPORT ID: ");
scanf(" %d",&sdetail.id);
printf("\nCHOOSE YOUR DESTINATION: ");
scanf(" %d",&splace.idestination);
if(splace.idestination==1)
{
splace.idestination==splace.jb;
}
else if(splace.idestination==2)
{
splace.idestination==splace.pen;
}
else if(splace.idestination==3)
{
splace.idestination==splace.ter;
}
else if(splace.idestination==4)
{
splace.idestination==splace.lg;
}
printf("\nCHOOSE YOUR WAY(1-ONE WAY,2-TWO WAY) :");
scanf(" %d",&sdetail.iway);
if (sdetail.iway==1)
{
sdetail.iway=sdetail.oneway;
printf("\nDeparture date:");
scanf(" %s",&sdetail.date);
printf("\nDeparture TIME: ");
scanf(" %s",&sdetail.itime);
if(splace.idestination == 1){
pay=130*1;
}
else if(splace.idestination == 2){
pay=150*1;
}
else if(splace.idestination == 3){
pay=170*1;
}
else if(splace.idestination == 4){
pay=200*1;
}
}
else if(sdetail.iway==2)
{
sdetail.iway=sdetail.twoway;
printf("\nDeparture date:");
scanf(" %s",&sdetail.date);
printf("\nDeparture TIME: ");
scanf(" %s",&sdetail.itime);
printf("\nReturn date:");
scanf(" %s",&sdetail.date1);
printf("\nReturn TIME: ");
scanf(" %s",&sdetail.itime2);
if(splace.idestination == 1){
pay=130*2;
}
else if(splace.idestination == 2){
pay=150*2;
}
else if(splace.idestination == 3){
pay=170*2;
}
else if(splace.idestination == 4){
pay=300*2;
}
}
else
{
printf("INVALID\n");
}
for (j=0; j<1; j++)
{
printf("\nChoose 1 for First Class and 2 for Economic class\t");
scanf("%i",&c);
switch(c)
{
case 1:
printf("\nFirst class\n");
printf("Seats available are 1-10.\n");
printf("Pick a seat:\n\n");
scanf("%i",&p);
sum=100;
s[j]=p;
for (i=0; i<j; i++)
{
if (s[j]==s[i])
{
printf("\n\nSeat taken.\n\n");
break;
}
}
break;
case 2:
printf("\nEconomical class\n");
printf("Seats available are 11-30.\n");
printf("Pick a seat:\n\n");
scanf("%i",&p);
sum=50;
s[j]=p;
for (i=0; i<j; i++)
{
if (s[j]==s[i])
{
printf("\n\nSeat taken.\n\n");
break;
}
}
break;
default:
break;
}
}
printf("\nCHOOSE YOUR FREE MEAL :");
scanf(" %s",&meals);
switch(meals)
{
case'A':
printf("KFC");
break;
case'B':
printf("MCD");
break;
case'C':
printf("DOMINOS");
break;
default :
break;
}
total_price=(pay+sum)*ticket;
}
}
void check()
{
printf("1.KL - JOHOR BHARU\t\t\t\t 0830-0930\t 1400-1500\n");
printf("2.KL - PENANG\t\t\t\t\t 0800-0900\t 1300-1400 \n");
printf("3.KL - TERENGGANU\t\t\t\t 1000-1120\t 1700-1820 \n");
printf("4.KL - LANGKAWI \t\t\t\t 0900-1015\t 1600-1715 ");
return;
}
void display()
{
struct detail sdetail;
struct place splace;
int p;
system("cls");
printf("\n===============================================================\n");
printf("NAME : %s\n",sdetail.cname);
printf("AGE : %d\n",sdetail.age);
printf("PASSPORT ID : %d\n",sdetail.id);
if(splace.idestination == 1){
strcpy(splace.jb,"KL-JOHOR BHARU");
printf("DESTINATION : %s\n",splace.jb);
}
else if(splace.idestination == 2){
strcpy(splace.pen,"KL-PENANG");
printf("DESTINATION : %s\n",splace.pen);
}
else if(splace.idestination == 3){
strcpy(splace.ter,"KL-TERENGGANU");
printf("DESTINATION : %s\n",splace.ter);
}
else if(splace.idestination == 4){
strcpy(splace.lg,"KL-LANGKAWI");
printf("DESTINATION : %s\n",splace.lg);
}
printf("SEAT : %d\n",p);
printf("DEPARTURE DATE: %s\n",sdetail.date);
printf("DEPARTURE TIME: %s\n",sdetail.itime);
printf("RETURN DATE: %s\n",sdetail.date1);
printf("RETUN TIME: %s\n",sdetail.itime2);
printf("\n===============================================================\n");
printf("\nPlease pay your ticket using online banking or master card.");
printf("\nThank you for choosing our airlines.Enjoy your holiday!");
return;
}
void cancel()
{
struct detail sdetail;
printf("Enter your PASSPORT ID: ");
scanf("%d",sdetail.id2);
if(sdetail.id2==sdetail.id)
{
printf("\nYour cancellation is successful.");
}
else
{
printf("\nYour cancellation is not successful.Sorry!");
}
return;
}
void save()
{
float total_price;
printf("TOTAL OVERALL : RM %.2f",total_price);
printf("\nPlease pay your ticket using online banking or master card.");
printf("\nThank you for choosing our airlines.Enjoy your holiday!");
return;
}
What I have tried:
i have almost done my coding but i don't have any ideas to do in void display area. i think i want to use pointers but i don't know how to it.Can you help me?