Advertisement
Guest User

Untitled

a guest
Jan 8th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.81 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5. struct Tripdate{
  6. int tripday;
  7. int tripmonth;
  8. int tripyear;
  9. };
  10. struct Bustime{
  11. int hours;
  12. int minute;
  13. };
  14. struct Bus{
  15.  
  16. int busplate;
  17. char bustripname[50];
  18. int seat[5];
  19. int ticketprice;
  20. struct Tripdate date;
  21. struct Bustime time;
  22.  
  23. };
  24. struct Passenger{
  25.  
  26. char custname[50];
  27. char custsurname[50];
  28. char custpassword;
  29. char custusername[50];
  30. struct Bus info[5];
  31. char username;
  32. char password;
  33. };
  34. struct Employe{
  35. char usern;
  36. char passw;
  37. };
  38. //decleration of functions
  39. struct Passenger customer[20];
  40. void Bus_information(struct Bus info[]);
  41. void Passenger_All_Information(struct Passenger customer[]);
  42. void read_EMP_usernameandpassword(FILE *fp1, struct Employe e[]);
  43. void read_PESS_usernameandpassword(FILE *fp2, struct Passenger customer[]);
  44. int size=0;
  45. main() {
  46.  
  47. FILE *fp;
  48. int choice;
  49. int k,m,i;
  50. int u,p;
  51. struct Bus info[5];
  52. struct Passenger customer[17];
  53. struct Employe worker[5];
  54.  
  55. printf("********** BUS TICKET RESERVATION SERVICE **********");
  56.  
  57.  
  58. printf("1-LOGIN AS ADMINISTRATOR \n2-LOGIN AS PASSENGER\n");
  59. scanf("%d",&choice);
  60.  
  61. switch(choice)
  62. {
  63.  
  64.  
  65.  
  66. case 1:
  67.  
  68. printf("Username : \n");
  69. scanf("%s",&u);
  70. printf("Password : \n");
  71. scanf("%s",&p);
  72.  
  73. fp=fopen("EMP_usernameandpassword.txt","r");
  74. read_EMP_usernameandpassword(fp,worker);
  75. fclose(fp);
  76.  
  77. 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");
  78. scanf("%d",&k);
  79. switch(k)
  80. {
  81. case 1:
  82. Passenger_All_Information(customer);
  83. break;
  84. case 2:
  85. Passenger_All_Information(customer);
  86. break;
  87. case 3:
  88. break;
  89. case 4:
  90. break;
  91.  
  92. }
  93. break;
  94. case 2:
  95.  
  96. //username and password function
  97.  
  98.  
  99. 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");
  100. scanf("%d",&m);
  101. switch(m)
  102. {
  103.  
  104. case 1:
  105. break;
  106. case 2:
  107. break;
  108. case 3:
  109. break;
  110. case 4:
  111. break;
  112. case 5:
  113. break;
  114.  
  115. }
  116. break;
  117. }
  118.  
  119.  
  120. return 0;
  121. }
  122. void Passenger_All_Information(struct Passenger customer[])
  123. {
  124.  
  125. //Customer 1 //Bus 1
  126.  
  127. strcpy(customer[0].custname,"ALI");
  128. strcpy(customer[0].custsurname,"YILMAZ");
  129. strcpy(customer[0].info[0].bustripname,"IZMIR-ADANA");
  130. customer[0].info[0].seat[0]=1;
  131. customer[0].info[0].date.tripday=7;
  132. customer[0].info[0].date.tripmonth=1;
  133. customer[0].info[0].date.tripyear=2016;
  134. customer[0].info[0].time.hours=8;
  135. customer[0].info[0].time.minute=00;
  136.  
  137. //Customer 2 //Bus 1
  138. strcpy(customer[1].custname,"AYSE");
  139. strcpy(customer[1].custsurname,"YILMAZ");
  140. strcpy(customer[1].info[0].bustripname,"IZMIR-ADANA");
  141. customer[1].info[0].seat[1]=2;
  142. customer[1].info[0].date.tripday=7;
  143. customer[1].info[0].date.tripmonth=1;
  144. customer[1].info[0].date.tripyear=2016;
  145. customer[1].info[0].time.hours=8;
  146. customer[1].info[0].time.minute=00;
  147.  
  148. //Customer 3 //Bus 1
  149. strcpy(customer[2].custname,"ESRA");
  150. strcpy(customer[2].custsurname,"ERYIGIT");
  151. strcpy(customer[2].info[0].bustripname,"IZMIR-ADANA");
  152. customer[2].info[0].seat[3]=4;
  153. customer[2].info[0].date.tripday=7;
  154. customer[2].info[0].date.tripmonth=1;
  155. customer[2].info[0].date.tripyear=2016;
  156. customer[2].info[0].time.hours=8;
  157. customer[2].info[0].time.minute=00;
  158.  
  159.  
  160. //Customer 4 Bus 2
  161. strcpy(customer[3].custname,"SEKIBE");
  162. strcpy(customer[3].custsurname,"EKSI");
  163. strcpy(customer[3].info[1].bustripname,"IZMIR-BURSA");
  164. customer[3].info[1].seat[1]=2;
  165. customer[3].info[1].date.tripday=8;
  166. customer[3].info[1].date.tripmonth=1;
  167. customer[3].info[1].date.tripyear=2016;
  168. customer[3].info[1].time.hours=17;
  169. customer[3].info[1].time.minute=30;
  170.  
  171. //Customer 5 Bus 2
  172. strcpy(customer[4].custname,"MERVE");
  173. strcpy(customer[4].custsurname,"DEMIR");
  174. strcpy(customer[4].info[1].bustripname,"IZMIR-BURSA");
  175. customer[4].info[1].seat[2]=3;
  176. customer[4].info[1].date.tripday=8;
  177. customer[4].info[1].date.tripmonth=1;
  178. customer[4].info[1].date.tripyear=2016;
  179. customer[4].info[1].time.hours=17;
  180. customer[4].info[1].time.minute=30;
  181.  
  182. //Customer 6 Bus 2
  183. strcpy(customer[5].custname,"MERVE");
  184. strcpy(customer[5].custsurname,"CIMEN");
  185. strcpy(customer[5].info[1].bustripname,"IZMIR-BURSA");
  186. customer[5].info[1].seat[3]=4;
  187. customer[5].info[1].date.tripday=8;
  188. customer[5].info[1].date.tripmonth=1;
  189. customer[5].info[1].date.tripyear=2016;
  190. customer[5].info[1].time.hours=17;
  191. customer[5].info[1].time.minute=30;
  192.  
  193. //Customer 7 Bus 3
  194. strcpy(customer[6].custname,"SUAT");
  195. strcpy(customer[6].custsurname,"HAMAN");
  196. strcpy(customer[6].info[2].bustripname,"IZMIR-ANKARA");
  197. customer[6].info[2].seat[0]=1;
  198. customer[6].info[2].date.tripday=9;
  199. customer[6].info[2].date.tripmonth=1;
  200. customer[6].info[2].date.tripyear=2016;
  201. customer[6].info[2].time.hours=12;
  202. customer[6].info[2].time.minute=30;
  203.  
  204.  
  205. //Customer 8 Bus 3
  206. strcpy(customer[7].custname,"CICEK");
  207. strcpy(customer[7].custsurname,"SENYURT");
  208. strcpy(customer[7].info[2].bustripname,"IZMIR-ANKARA");
  209. customer[7].info[2].seat[1]=2;
  210. customer[7].info[2].date.tripday=9;
  211. customer[7].info[2].date.tripmonth=1;
  212. customer[7].info[2].date.tripyear=2016;
  213. customer[7].info[2].time.hours=12;
  214. customer[7].info[2].time.minute=30;
  215.  
  216. //Customer 9 Bus 3
  217. strcpy(customer[8].custname,"TUANA");
  218. strcpy(customer[8].custsurname,"ALTUN");
  219. strcpy(customer[8].info[2].bustripname,"IZMIR-ANKARA");
  220. customer[8].info[2].seat[2]=3;
  221. customer[8].info[2].date.tripday=9;
  222. customer[8].info[2].date.tripmonth=1;
  223. customer[8].info[2].date.tripyear=2016;
  224. customer[8].info[2].time.hours=12;
  225. customer[8].info[2].time.minute=30;
  226.  
  227. //Customer 10 Bus 3
  228. strcpy(customer[9].custname,"TUNA");
  229. strcpy(customer[9].custsurname,"ALTUN");
  230. strcpy(customer[9].info[2].bustripname,"IZMIR-ANKARA");
  231. customer[9].info[2].seat[3]=4;
  232. customer[9].info[2].date.tripday=9;
  233. customer[9].info[2].date.tripmonth=1;
  234. customer[9].info[2].date.tripyear=2016;
  235. customer[9].info[2].time.hours=12;
  236. customer[9].info[2].time.minute=30;
  237.  
  238. //Customer 11 Bus 3
  239. strcpy(customer[10].custname,"MEHMET");
  240. strcpy(customer[10].custsurname,"OCAK");
  241. strcpy(customer[10].info[2].bustripname,"IZMIR-ANKARA");
  242. customer[10].info[2].seat[4]=5;
  243. customer[10].info[2].date.tripday=9;
  244. customer[10].info[2].date.tripmonth=1;
  245. customer[10].info[2].date.tripyear=2016;
  246. customer[10].info[2].time.hours=12;
  247. customer[10].info[2].time.minute=30;
  248.  
  249. //Customer 12 Bus 4
  250. strcpy(customer[11].custname,"ALPEREN");
  251. strcpy(customer[11].custsurname,"EKSI");
  252. strcpy(customer[11].info[3].bustripname,"IZMIR-ISPARTA");
  253. customer[11].info[3].seat[0]=1;
  254. customer[11].info[3].date.tripday=10;
  255. customer[11].info[3].date.tripmonth=1;
  256. customer[11].info[3].date.tripyear=2016;
  257. customer[11].info[3].time.hours=10;
  258. customer[11].info[3].time.minute=15;
  259.  
  260.  
  261.  
  262. //Customer 13 Bus 5
  263. strcpy(customer[12].custname,"PINAR");
  264. strcpy(customer[12].custsurname,"SAHAN");
  265. strcpy(customer[12].info[3].bustripname,"IZMIR-ISPARTA");
  266. customer[12].info[3].seat[1]=2;
  267. customer[12].info[3].date.tripday=10;
  268. customer[12].info[3].date.tripmonth=1;
  269. customer[12].info[3].date.tripyear=2016;
  270. customer[12].info[3].time.hours=10;
  271. customer[12].info[3].time.minute=15;
  272.  
  273. //Customer 14 Bus 4
  274. strcpy(customer[13].custname,"BETUL");
  275. strcpy(customer[13].custsurname,"YILDIZ");
  276. strcpy(customer[13].info[3].bustripname,"IZMIR-ISPARTA");
  277. customer[13].info[3].seat[4]=5;
  278. customer[13].info[3].date.tripday=10;
  279. customer[13].info[3].date.tripmonth=1;
  280. customer[13].info[3].date.tripyear=2016;
  281. customer[13].info[3].time.hours=10;
  282. customer[13].info[3].time.minute=15;
  283.  
  284. //Customer 15 Bus 5
  285. strcpy(customer[14].custname,"FATMA");
  286. strcpy(customer[14].custsurname,"CETIN");
  287. strcpy(customer[14].info[4].bustripname,"IZMIR-ERZURUM");
  288. customer[14].info[4].seat[0]=1;
  289. customer[14].info[4].date.tripday=8;
  290. customer[14].info[4].date.tripmonth=1;
  291. customer[14].info[4].date.tripyear=2016;
  292. customer[14].info[4].time.hours=12;
  293. customer[14].info[4].time.minute=45;
  294.  
  295. //Customer 16 Bus 5
  296. strcpy(customer[15].custname,"CETIN");
  297. strcpy(customer[15].custsurname,"BULUT");
  298. strcpy(customer[15].info[4].bustripname,"IZMIR-ERZURUM");
  299. customer[15].info[4].seat[1]=2;
  300. customer[15].info[4].date.tripday=8;
  301. customer[15].info[4].date.tripmonth=1;
  302. customer[15].info[4].date.tripyear=2016;
  303. customer[15].info[4].time.hours=12;
  304. customer[15].info[4].time.minute=45;
  305.  
  306. //Customer 17 Bus 5
  307. strcpy(customer[16].custname,"GAMZE");
  308. strcpy(customer[16].custsurname,"OZTURK");
  309. strcpy(customer[16].info[4].bustripname,"IZMIR-ERZURUM");
  310. customer[16].info[4].seat[3]=4;
  311. customer[16].info[4].date.tripday=8;
  312. customer[16].info[4].date.tripmonth=1;
  313. customer[16].info[4].date.tripyear=2016;
  314. customer[16].info[4].time.hours=12;
  315. customer[16].info[4].time.minute=45;
  316.  
  317.  
  318. }
  319.  
  320. void Bus_information(struct Bus info[])
  321. {
  322. //bus 1
  323. strcpy(info[0].busplate,"35 AA 350");
  324. strcpy(info[0].bustripname,"IZMIR-ADANA");
  325. info[0].date.tripday=7;
  326. info[0].date.tripmonth=1;
  327. info[0].date.tripyear=2016;
  328. info[0].ticketprice=70;
  329. info[0].time.hours=8;
  330. info[0].time.minute=00;
  331.  
  332. //bus 2
  333. strcpy(info[1].busplate,"35 AA 351");
  334. strcpy(info[1].bustripname,"IZMIR-BURSA");
  335. info[1].date.tripday=8;
  336. info[1].date.tripmonth=1;
  337. info[1].date.tripyear=2016;
  338. info[1].ticketprice=35;
  339. info[1].time.hours=17;
  340. info[1].time.minute=30;
  341.  
  342. //bus3
  343. strcpy(info[2].busplate,"35 AA 352");
  344. strcpy(info[2].bustripname,"IZMIR-ANKARA");
  345. info[2].date.tripday=9;
  346. info[2].date.tripmonth=1;
  347. info[2].date.tripyear=2016;
  348. info[2].ticketprice=50;
  349. info[2].time.hours=12;
  350. info[2].time.minute=30;
  351.  
  352. //Bus 4
  353. strcpy(info[3].busplate,"35 AA 353");
  354. strcpy(info[3].bustripname,"IZMIR-ISPARTA");
  355. info[3].date.tripday=10;
  356. info[3].date.tripmonth=1;
  357. info[3].date.tripyear=2016;
  358. info[3].ticketprice=50;
  359. info[3].time.hours=10;
  360. info[3].time.minute=15;
  361.  
  362. //Bus 5
  363. strcpy(info[4].busplate,"35 AA 354");
  364. strcpy(info[4].bustripname,"IZMIR-ERZURUM");
  365. info[4].date.tripday=8;
  366. info[4].date.tripmonth=1;
  367. info[4].date.tripyear=2016;
  368. info[4].ticketprice=85;
  369. info[4].time.hours=12;
  370. info[4].time.minute=45;
  371.  
  372. }
  373. void read_EMP_usernameandpassword(FILE *fp1, struct Employe e[])
  374. {
  375. int size=0;
  376. int u,p;
  377. while(!feof(fp1))
  378. {
  379. fscanf(fp1,"%s%s",e[size].usern,e[size].passw);
  380. if(strcpm(e[size].usern,u)==0 && strcmp(e[size].passw,p)==0);
  381. break;
  382. size++;
  383. }
  384. return 0;
  385. }
  386. void read_PESS_usernameandpassword(FILE *fp2, struct Passenger customer[]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement