Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- struct Tripdate{
- int tripday;
- int tripmonth;
- int tripyear;
- };
- struct Bustime{
- int hours;
- int minute;
- };
- struct Bus{
- int busplate;
- char bustripname[50];
- int seat[5];
- int ticketprice;
- struct Tripdate date;
- struct Bustime time;
- };
- struct Passenger{
- char custname[50];
- char custsurname[50];
- char custpassword;
- char custusername[50];
- struct Bus info[5];
- char username;
- char password;
- };
- struct Employe{
- char usern;
- char passw;
- };
- //decleration of functions
- struct Passenger customer[20];
- void Bus_information(struct Bus info[]);
- void Passenger_All_Information(struct Passenger customer[]);
- void read_EMP_usernameandpassword(FILE *fp1, struct Employe e[]);
- void read_PESS_usernameandpassword(FILE *fp2, struct Passenger customer[]);
- int size=0;
- main() {
- FILE *fp;
- int choice;
- int k,m,i;
- int u,p;
- struct Bus info[5];
- struct Passenger customer[17];
- struct Employe worker[5];
- printf("********** BUS TICKET RESERVATION SERVICE **********");
- printf("1-LOGIN AS ADMINISTRATOR \n2-LOGIN AS PASSENGER\n");
- scanf("%d",&choice);
- switch(choice)
- {
- case 1:
- printf("Username : \n");
- scanf("%s",&u);
- printf("Password : \n");
- scanf("%s",&p);
- fp=fopen("EMP_usernameandpassword.txt","r");
- read_EMP_usernameandpassword(fp,worker);
- fclose(fp);
- printf("1. Display all information of all passengers\n2. Display all passengers which took tickets for a specific bus trip\n3. Cancel a ticket\n4. Print the ticket for a passenger\n0-Return the MENU\n");
- scanf("%d",&k);
- switch(k)
- {
- case 1:
- Passenger_All_Information(customer);
- break;
- case 2:
- Passenger_All_Information(customer);
- break;
- case 3:
- break;
- case 4:
- break;
- }
- break;
- case 2:
- //username and password function
- printf("1. Buy a ticket for a trip\n2. Display your online ticket\n3. Change ticket information(For ex trip or seat or bus)\n4. Display available and unavailable seats for a specific bus trip\n5. Search a ticket\n0-Return the MENU\n");
- scanf("%d",&m);
- switch(m)
- {
- case 1:
- break;
- case 2:
- break;
- case 3:
- break;
- case 4:
- break;
- case 5:
- break;
- }
- break;
- }
- return 0;
- }
- void Passenger_All_Information(struct Passenger customer[])
- {
- //Customer 1 //Bus 1
- strcpy(customer[0].custname,"ALI");
- strcpy(customer[0].custsurname,"YILMAZ");
- strcpy(customer[0].info[0].bustripname,"IZMIR-ADANA");
- customer[0].info[0].seat[0]=1;
- customer[0].info[0].date.tripday=7;
- customer[0].info[0].date.tripmonth=1;
- customer[0].info[0].date.tripyear=2016;
- customer[0].info[0].time.hours=8;
- customer[0].info[0].time.minute=00;
- //Customer 2 //Bus 1
- strcpy(customer[1].custname,"AYSE");
- strcpy(customer[1].custsurname,"YILMAZ");
- strcpy(customer[1].info[0].bustripname,"IZMIR-ADANA");
- customer[1].info[0].seat[1]=2;
- customer[1].info[0].date.tripday=7;
- customer[1].info[0].date.tripmonth=1;
- customer[1].info[0].date.tripyear=2016;
- customer[1].info[0].time.hours=8;
- customer[1].info[0].time.minute=00;
- //Customer 3 //Bus 1
- strcpy(customer[2].custname,"ESRA");
- strcpy(customer[2].custsurname,"ERYIGIT");
- strcpy(customer[2].info[0].bustripname,"IZMIR-ADANA");
- customer[2].info[0].seat[3]=4;
- customer[2].info[0].date.tripday=7;
- customer[2].info[0].date.tripmonth=1;
- customer[2].info[0].date.tripyear=2016;
- customer[2].info[0].time.hours=8;
- customer[2].info[0].time.minute=00;
- //Customer 4 Bus 2
- strcpy(customer[3].custname,"SEKIBE");
- strcpy(customer[3].custsurname,"EKSI");
- strcpy(customer[3].info[1].bustripname,"IZMIR-BURSA");
- customer[3].info[1].seat[1]=2;
- customer[3].info[1].date.tripday=8;
- customer[3].info[1].date.tripmonth=1;
- customer[3].info[1].date.tripyear=2016;
- customer[3].info[1].time.hours=17;
- customer[3].info[1].time.minute=30;
- //Customer 5 Bus 2
- strcpy(customer[4].custname,"MERVE");
- strcpy(customer[4].custsurname,"DEMIR");
- strcpy(customer[4].info[1].bustripname,"IZMIR-BURSA");
- customer[4].info[1].seat[2]=3;
- customer[4].info[1].date.tripday=8;
- customer[4].info[1].date.tripmonth=1;
- customer[4].info[1].date.tripyear=2016;
- customer[4].info[1].time.hours=17;
- customer[4].info[1].time.minute=30;
- //Customer 6 Bus 2
- strcpy(customer[5].custname,"MERVE");
- strcpy(customer[5].custsurname,"CIMEN");
- strcpy(customer[5].info[1].bustripname,"IZMIR-BURSA");
- customer[5].info[1].seat[3]=4;
- customer[5].info[1].date.tripday=8;
- customer[5].info[1].date.tripmonth=1;
- customer[5].info[1].date.tripyear=2016;
- customer[5].info[1].time.hours=17;
- customer[5].info[1].time.minute=30;
- //Customer 7 Bus 3
- strcpy(customer[6].custname,"SUAT");
- strcpy(customer[6].custsurname,"HAMAN");
- strcpy(customer[6].info[2].bustripname,"IZMIR-ANKARA");
- customer[6].info[2].seat[0]=1;
- customer[6].info[2].date.tripday=9;
- customer[6].info[2].date.tripmonth=1;
- customer[6].info[2].date.tripyear=2016;
- customer[6].info[2].time.hours=12;
- customer[6].info[2].time.minute=30;
- //Customer 8 Bus 3
- strcpy(customer[7].custname,"CICEK");
- strcpy(customer[7].custsurname,"SENYURT");
- strcpy(customer[7].info[2].bustripname,"IZMIR-ANKARA");
- customer[7].info[2].seat[1]=2;
- customer[7].info[2].date.tripday=9;
- customer[7].info[2].date.tripmonth=1;
- customer[7].info[2].date.tripyear=2016;
- customer[7].info[2].time.hours=12;
- customer[7].info[2].time.minute=30;
- //Customer 9 Bus 3
- strcpy(customer[8].custname,"TUANA");
- strcpy(customer[8].custsurname,"ALTUN");
- strcpy(customer[8].info[2].bustripname,"IZMIR-ANKARA");
- customer[8].info[2].seat[2]=3;
- customer[8].info[2].date.tripday=9;
- customer[8].info[2].date.tripmonth=1;
- customer[8].info[2].date.tripyear=2016;
- customer[8].info[2].time.hours=12;
- customer[8].info[2].time.minute=30;
- //Customer 10 Bus 3
- strcpy(customer[9].custname,"TUNA");
- strcpy(customer[9].custsurname,"ALTUN");
- strcpy(customer[9].info[2].bustripname,"IZMIR-ANKARA");
- customer[9].info[2].seat[3]=4;
- customer[9].info[2].date.tripday=9;
- customer[9].info[2].date.tripmonth=1;
- customer[9].info[2].date.tripyear=2016;
- customer[9].info[2].time.hours=12;
- customer[9].info[2].time.minute=30;
- //Customer 11 Bus 3
- strcpy(customer[10].custname,"MEHMET");
- strcpy(customer[10].custsurname,"OCAK");
- strcpy(customer[10].info[2].bustripname,"IZMIR-ANKARA");
- customer[10].info[2].seat[4]=5;
- customer[10].info[2].date.tripday=9;
- customer[10].info[2].date.tripmonth=1;
- customer[10].info[2].date.tripyear=2016;
- customer[10].info[2].time.hours=12;
- customer[10].info[2].time.minute=30;
- //Customer 12 Bus 4
- strcpy(customer[11].custname,"ALPEREN");
- strcpy(customer[11].custsurname,"EKSI");
- strcpy(customer[11].info[3].bustripname,"IZMIR-ISPARTA");
- customer[11].info[3].seat[0]=1;
- customer[11].info[3].date.tripday=10;
- customer[11].info[3].date.tripmonth=1;
- customer[11].info[3].date.tripyear=2016;
- customer[11].info[3].time.hours=10;
- customer[11].info[3].time.minute=15;
- //Customer 13 Bus 5
- strcpy(customer[12].custname,"PINAR");
- strcpy(customer[12].custsurname,"SAHAN");
- strcpy(customer[12].info[3].bustripname,"IZMIR-ISPARTA");
- customer[12].info[3].seat[1]=2;
- customer[12].info[3].date.tripday=10;
- customer[12].info[3].date.tripmonth=1;
- customer[12].info[3].date.tripyear=2016;
- customer[12].info[3].time.hours=10;
- customer[12].info[3].time.minute=15;
- //Customer 14 Bus 4
- strcpy(customer[13].custname,"BETUL");
- strcpy(customer[13].custsurname,"YILDIZ");
- strcpy(customer[13].info[3].bustripname,"IZMIR-ISPARTA");
- customer[13].info[3].seat[4]=5;
- customer[13].info[3].date.tripday=10;
- customer[13].info[3].date.tripmonth=1;
- customer[13].info[3].date.tripyear=2016;
- customer[13].info[3].time.hours=10;
- customer[13].info[3].time.minute=15;
- //Customer 15 Bus 5
- strcpy(customer[14].custname,"FATMA");
- strcpy(customer[14].custsurname,"CETIN");
- strcpy(customer[14].info[4].bustripname,"IZMIR-ERZURUM");
- customer[14].info[4].seat[0]=1;
- customer[14].info[4].date.tripday=8;
- customer[14].info[4].date.tripmonth=1;
- customer[14].info[4].date.tripyear=2016;
- customer[14].info[4].time.hours=12;
- customer[14].info[4].time.minute=45;
- //Customer 16 Bus 5
- strcpy(customer[15].custname,"CETIN");
- strcpy(customer[15].custsurname,"BULUT");
- strcpy(customer[15].info[4].bustripname,"IZMIR-ERZURUM");
- customer[15].info[4].seat[1]=2;
- customer[15].info[4].date.tripday=8;
- customer[15].info[4].date.tripmonth=1;
- customer[15].info[4].date.tripyear=2016;
- customer[15].info[4].time.hours=12;
- customer[15].info[4].time.minute=45;
- //Customer 17 Bus 5
- strcpy(customer[16].custname,"GAMZE");
- strcpy(customer[16].custsurname,"OZTURK");
- strcpy(customer[16].info[4].bustripname,"IZMIR-ERZURUM");
- customer[16].info[4].seat[3]=4;
- customer[16].info[4].date.tripday=8;
- customer[16].info[4].date.tripmonth=1;
- customer[16].info[4].date.tripyear=2016;
- customer[16].info[4].time.hours=12;
- customer[16].info[4].time.minute=45;
- }
- void Bus_information(struct Bus info[])
- {
- //bus 1
- strcpy(info[0].busplate,"35 AA 350");
- strcpy(info[0].bustripname,"IZMIR-ADANA");
- info[0].date.tripday=7;
- info[0].date.tripmonth=1;
- info[0].date.tripyear=2016;
- info[0].ticketprice=70;
- info[0].time.hours=8;
- info[0].time.minute=00;
- //bus 2
- strcpy(info[1].busplate,"35 AA 351");
- strcpy(info[1].bustripname,"IZMIR-BURSA");
- info[1].date.tripday=8;
- info[1].date.tripmonth=1;
- info[1].date.tripyear=2016;
- info[1].ticketprice=35;
- info[1].time.hours=17;
- info[1].time.minute=30;
- //bus3
- strcpy(info[2].busplate,"35 AA 352");
- strcpy(info[2].bustripname,"IZMIR-ANKARA");
- info[2].date.tripday=9;
- info[2].date.tripmonth=1;
- info[2].date.tripyear=2016;
- info[2].ticketprice=50;
- info[2].time.hours=12;
- info[2].time.minute=30;
- //Bus 4
- strcpy(info[3].busplate,"35 AA 353");
- strcpy(info[3].bustripname,"IZMIR-ISPARTA");
- info[3].date.tripday=10;
- info[3].date.tripmonth=1;
- info[3].date.tripyear=2016;
- info[3].ticketprice=50;
- info[3].time.hours=10;
- info[3].time.minute=15;
- //Bus 5
- strcpy(info[4].busplate,"35 AA 354");
- strcpy(info[4].bustripname,"IZMIR-ERZURUM");
- info[4].date.tripday=8;
- info[4].date.tripmonth=1;
- info[4].date.tripyear=2016;
- info[4].ticketprice=85;
- info[4].time.hours=12;
- info[4].time.minute=45;
- }
- void read_EMP_usernameandpassword(FILE *fp1, struct Employe e[])
- {
- int size=0;
- int u,p;
- while(!feof(fp1))
- {
- fscanf(fp1,"%s%s",e[size].usern,e[size].passw);
- if(strcpm(e[size].usern,u)==0 && strcmp(e[size].passw,p)==0);
- break;
- size++;
- }
- return 0;
- }
- void read_PESS_usernameandpassword(FILE *fp2, struct Passenger customer[]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement