Advertisement
pkbagchi

DIU Bus Service

Mar 25th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 17.71 KB | None | 0 0
  1. ///..........................DIU Special Bus Services....................................................
  2. ///..........................Header file.................................................................
  3. #include<stdio.h>
  4. #include<stdlib.h>
  5. #include<string.h>
  6. #include<Windows.h>
  7. ///..........................End of Header file..........................................................
  8. int rotID=0;
  9. struct AdminRootAdd{
  10.     int rootID;
  11.     char rootname[30];
  12.     float dist;
  13.     int rent;
  14.     struct AdminRootAdd* link;
  15. };
  16. struct AdminRootAdd* fst = NULL;
  17. struct AdminRootAdd* lst = NULL;
  18. ///..........................Global variable for root....................................................
  19. int rootSelct;
  20. float distance;
  21. int rent;
  22. ///..........................End Global variable for root................................................
  23. ///..........................Structure for Travel History................................................
  24. struct rootadd{
  25.     char ID[25];
  26.     char rootName[30];
  27.     float distance;
  28.     int rent;
  29.     int day;
  30.     int month;
  31.     int year;
  32.     struct rootadd* link;
  33. };
  34. struct rootadd* NEW = NULL;
  35. ///..........................End Structure for Travel History............................................
  36. ///..........................Structure for create Student Account........................................
  37. struct createAccount{
  38.     char ID[25];
  39.     char NAME[25];
  40.     struct createAccount* link;
  41. };
  42. struct createAccount* head = NULL;
  43. ///...........................End Structure for create Student Account...................................
  44. ///...........................Some Important Users Defined Functions.....................................
  45. void submain();
  46. void home();
  47. void registernewStudent();
  48. void ShowregistedStudent();
  49. void StudentTravelHistory();
  50. void rootSelect();
  51. void enteryourchoice();
  52. int deletstudenthistory();
  53. void firstInsertSomeStudent(char iD[],char namE[]);
  54. void rootcreateAdim();
  55. void firstAssignRoot();
  56. void firstAssignRoot2();
  57. ///............................End of Some Important Users Defined Functions.............................
  58. ///..........................Global variable for delete history..........................................
  59. char idd[20];
  60. ///..........................End Global variable for delete history......................................
  61. ///.............................Global variable For Admin................................................
  62.     char adminname[25];
  63.     char adminIdCreate[25];
  64.     char adminpasswordCreate[25];
  65.     char adminId[25];
  66.     char adminpassword[25];
  67.     void adminsignIn();
  68.     void adminsignUp();
  69. ///..............................End of Global variable For Admin........................................
  70. ///..........................Main Function...............................................................
  71. void main()
  72. {
  73.     system ("COLOR 1f");
  74.     ///......Some Student Accounts...................................
  75.     firstAssignRoot();
  76.     firstAssignRoot2();
  77.     char iD1[20]="171-15-1111";
  78.     char namE1[20]="Amit";
  79.     firstInsertSomeStudent(iD1,namE1);
  80.     char iD2[20]="171-15-0000";
  81.     char namE2[20]="Snigdha";
  82.     firstInsertSomeStudent(iD2,namE2);
  83.     char iD3[20]="163-15-8512";
  84.     char namE3[20]="Partha";
  85.     firstInsertSomeStudent(iD3,namE3);
  86.     char iD4[20]="171-15-8998";
  87.     char namE4[20]="Joy";
  88.     firstInsertSomeStudent(iD4,namE4);
  89.     char iD5[20]="171-15-8875";
  90.     char namE5[20]="Sakil";
  91.     firstInsertSomeStudent(iD5,namE5);
  92.     char iD6[20]="171-15-8636";
  93.     char namE6[20]="Mijan";
  94.     firstInsertSomeStudent(iD6,namE6);
  95.     char iD7[20]="171-15-8640";
  96.     char namE7[20]="Adol";
  97.     firstInsertSomeStudent(iD7,namE7);
  98.     ///......End Some Student Accounts...............................
  99.     submain();
  100. }
  101. ///......................End of Main Function............................................................
  102. ///......................Sub-Main Function...............................................................
  103. void submain()
  104. {
  105.     printf("****************************************************************************************************************\n************************************** Welcome to DIU special Bus Services *************************************\n****************************************************************************************************************\n");
  106.     while(1){
  107.     printf("\t\t\t\t\t................................\n");
  108.     printf("\t\t\t\t\t....Admin Sign Up or Sign In....\n\t\t\t\t\t................................\n\n \t\t\t\t\t\t1. Sign In\n \t\t\t\t\t\t2. Sign Up\n \t\t\t\t\t\t0. Exit\n");
  109.     int cho;
  110.     printf("\n\t\t\t\t\tChoice Option : ");
  111.     scanf("%d",&cho);
  112.     if(cho==1) adminsignIn();
  113.     if(cho==2) adminsignUp();
  114.     if(cho==0){
  115.         printf("\n\t\t\t\t\t*****Thank You*****\n");
  116.         break;
  117.     }
  118.     }
  119. }
  120. ///......................End of Sub-Main Function........................................................
  121. ///......................Admin Sign In Function..........................................................
  122. void adminsignIn()
  123. {
  124.     printf("\n\t\t\t\t\tEnter Admin ID :");
  125.     scanf("%s",&adminId);
  126.     printf("\n\t\t\t\t\tEnter Password :");
  127.     scanf("%s",&adminpassword);
  128.     if(strcmp(adminId,adminIdCreate)==0 && strcmp(adminpasswordCreate,adminpassword)==0)
  129.     {
  130.         printf("\t\t\t\t\tLogin Success!\n");
  131.         home();
  132.     }else{
  133.         printf("\n\t\t\t\t\tAdmin Id or Password is incorrect!\n");
  134.     }
  135. }
  136. ///.......................End of Admin Sign In Function..................................................
  137. ///.......................Admin Sign Up Function.........................................................
  138. void adminsignUp()
  139. {
  140.     printf("\n\t\t\t\t\tEnter Bus Number : ");
  141.     scanf("%s",&adminname);
  142.     printf("\n\t\t\t\t\tEnter Admin ID : ");
  143.     scanf("%s",&adminIdCreate);
  144.     printf("\n\t\t\t\t\tEnter Admin New Password : ");
  145.     scanf("%s",&adminpasswordCreate);
  146.     printf("\n\t\t\t\t\tWelcome %s\n",adminname);
  147.     home();
  148. }
  149. ///.......................End of Admin Sign Up Function..................................................
  150. ///.......................Home option Function...........................................................
  151. void home()
  152. {
  153.     printf(" .....................................................................................................................\n");
  154.     printf(" 1.Home 2.Register New Student 3.Registered Student 4.Travel 5.Travel History 6. Delete History 7. Root Add 0.Sign Out\n");
  155.     printf(" .....................................................................................................................\n");
  156.     printf(" ..Home..\n");
  157.     printf(" ........\n");
  158.     printf("\n Bus Number : %s\n\n",adminname);
  159.     printf("\tThe DIU special bus services.\n This Software store all student travel history and count every student travel cost.\n Only Admin control this software. \n\n\t..........\n");
  160.     enteryourchoice();
  161. }
  162. ///.......................End of Home option Function....................................................
  163. ///.......................Registration of new student Function...........................................
  164. void registernewStudent()
  165. {
  166.     printf(" .....................................................................................................................\n");
  167.     printf(" 1.Home 2.Register New Student 3.Registered Student 4.Travel 5.Travel History 6. Delete History 7. Root Add 0.Sign Out\n");
  168.     printf(" .....................................................................................................................\n");
  169.     printf(" ..Register New Student..\n");
  170.     printf(" ........................\n");
  171.     printf("\n Bus Number : %s\n\n",adminname);
  172.     struct createAccount* newStudent = (struct createAccount*)malloc(sizeof(struct createAccount));
  173.     printf("Enter Student University ID : ");
  174.     scanf("%s",&newStudent->ID);
  175.     printf("Enter Student Name : ");
  176.     scanf("%s",&newStudent->NAME);
  177.     newStudent->link = NULL;
  178.     if(head==NULL)
  179.     {
  180.         head = newStudent;
  181.     }else{
  182.         newStudent->link = head;
  183.         head = newStudent;
  184.     }
  185.     enteryourchoice();
  186. }
  187. ///.......................End Registration of new student Function.......................................
  188. void firstInsertSomeStudent(char iD[],char namE[])
  189. {
  190.     struct createAccount* firstAddStudent = (struct createAccount*)malloc(sizeof(struct createAccount));
  191.     strcpy(firstAddStudent->ID,iD);
  192.     strcpy(firstAddStudent->NAME,namE);
  193.     firstAddStudent->link = NULL;
  194.     if(head==NULL)
  195.     {
  196.         head = firstAddStudent;
  197.     }else{
  198.         firstAddStudent->link = head;
  199.         head = firstAddStudent;
  200.     }
  201. }
  202. ///.......................Show already registered student Function.......................................
  203. void ShowregistedStudent()
  204. {
  205.     printf(" .....................................................................................................................\n");
  206.     printf(" 1.Home 2.Register New Student 3.Registered Student 4.Travel 5.Travel History 6. Delete History 7. Root Add 0.Sign Out\n");
  207.     printf(" .....................................................................................................................\n");
  208.     printf(" ..Registered Student..\n");
  209.     printf(" ......................\n");
  210.     printf("\n Bus Number : %s\n\n",adminname);
  211.     struct createAccount* dis = head;
  212.     int i=1;
  213.     printf(" All Registered student :\n");
  214.     printf(" ID\tStudent ID\tStudent Name\n");
  215.     while(dis!=NULL)
  216.     {
  217.         printf(" %d\t%s\t%s\n",i,dis->ID,dis->NAME);
  218.         i++;
  219.         dis = dis->link;
  220.  
  221.     }
  222.     enteryourchoice();
  223. }
  224. ///.......................End of Show already registered student Function................................
  225. ///.......................Student travel history Function................................................
  226. void StudentTravelHistory()
  227. {
  228.     printf(" .....................................................................................................................\n");
  229.     printf(" 1.Home 2.Register New Student 3.Registered Student 4.Travel 5.Travel History 6. Delete History 7. Root Add 0.Sign Out\n");
  230.     printf(" .....................................................................................................................\n");
  231.     printf(" ..Travel History..\n");
  232.     printf(" ..................\n");
  233.     printf("\n Enter the ID, which student's travel history you want to sow : ");
  234.     int TotalRent=0;
  235.     char id[20];
  236.     scanf("%s",&id);
  237.     struct rootadd* sowHis = NEW;
  238.     printf("\n History of ID is: %s\n",id);
  239.     struct createAccount* namesw = head;
  240.     while(namesw!=NULL){
  241.         if(strcmp(namesw->ID,id)==0){
  242.             printf(" Name \t\t: %s\n",namesw->NAME);
  243.             break;
  244.         }
  245.         namesw = namesw->link;
  246.     }
  247.     printf("\n DD-MM-YYYY \t Place Name \t Distance \t Rent\n");
  248.     while(sowHis!=NULL)
  249.     {
  250.         if(strcmp(id,sowHis->ID)==0)
  251.         {
  252.             printf("\n %d-%d-%d \t %s \t %.1f km. \t %d Taka",sowHis->day,sowHis->month,sowHis->year,sowHis->rootName,sowHis->distance,sowHis->rent);
  253.             TotalRent+=sowHis->rent;
  254.         }
  255.         sowHis = sowHis->link;
  256.     }
  257.     if(TotalRent==0){
  258.         printf("\n Oops!! No travel history of ID : %s\n\n",id);
  259.     }else
  260.     printf("\nTotal rent is : %d Taka.\n\n",TotalRent);
  261.     enteryourchoice();
  262.  
  263. }
  264. ///.......................End of Student travel history Function.........................................
  265. ///.......................Add all student travel Function(one by one add)................................
  266. void addRoot(int rotidd)
  267. {
  268.     SYSTEMTIME stime;
  269.     GetSystemTime(&stime);
  270.     struct createAccount* che = head;
  271.     struct rootadd* add = (struct rootadd*)malloc(sizeof(struct rootadd));
  272.     struct AdminRootAdd* tm = fst;
  273.     while(tm!=NULL){
  274.         if(tm->rootID==rotidd){
  275.             break;
  276.         }
  277.         tm = tm->link;
  278.     }
  279.     printf("Enter student University ID : ");
  280.     scanf("%s",&add->ID);
  281.     while(1){
  282.             if(che==NULL){
  283.             printf("\nThere is no account of ID : %s. Please Create New account.\n",add->ID);
  284.             break;}
  285.     if(strcmp(add->ID,che->ID)==0){
  286.     strcpy(add->rootName,tm->rootname);
  287.     add->distance = tm->dist;
  288.     add->rent = tm->rent;
  289.     add->day = stime.wDay;
  290.     add->month = stime.wMonth;
  291.     add->year = stime.wYear;
  292.     add->link = NULL;
  293.  
  294.     if(NEW==NULL){
  295.         NEW = add;
  296.     }else{
  297.         add->link = NEW;
  298.         NEW = add;
  299.     }
  300.     break;
  301.     }
  302.         che = che->link;
  303.     }
  304. }
  305. ///.......................End of Add all student travel Function(one by one add).........................
  306. ///.......................Choose all potion Function.....................................................
  307. void enteryourchoice()
  308. {
  309.     printf(" Enter New choice : ");
  310.     int co,deletcount,enterchoiceCount=1;
  311.     scanf("%d",&co);
  312.     switch(co)
  313.     {
  314.         case 1:
  315.         home();
  316.         break;
  317.         case 2:
  318.         registernewStudent();
  319.         break;
  320.         case 3:
  321.         ShowregistedStudent();
  322.         break;
  323.         case 4:
  324.         rootSelect();
  325.         break;
  326.         case 5:
  327.         StudentTravelHistory();
  328.         break;
  329.         case 6:
  330.             printf(" .....................................................................................................................\n");
  331.             printf(" 1.Home 2.Register New Student 3.Registered Student 4.Travel 5.Travel History 6. Delete History 7. Root Add 0.Sign Out\n");
  332.             printf(" .....................................................................................................................\n");
  333.             printf(" ..Delete History..\n");
  334.             printf(" ..................\n");
  335.             printf("Enter student ID, whose history you want to delete : ");
  336.             scanf("%s",&idd);
  337.             while(1){
  338.                 deletcount=deletstudenthistory();
  339.                 if(deletcount==1) {
  340.                     printf("All history deleted.\n");
  341.                     break;
  342.                 }
  343.             }
  344.             enterchoiceCount++;
  345.         break;
  346.         case 7:
  347.             rootcreateAdim();
  348.             break;
  349.         case 0:
  350.         submain();
  351.         break;
  352.     }
  353.     if(enterchoiceCount==2) enteryourchoice();
  354. }
  355. ///.......................End of Choose all potion Function..............................................
  356. ///.......................Delete Student travel history Function(after payment)..........................
  357. int deletstudenthistory()
  358. {
  359.  
  360.     int cou=1,xeicuteOrNot=0;
  361.     struct rootadd* del = NEW;
  362.     struct rootadd* pre = NEW;
  363.     while(del!=NULL)
  364.     {
  365.         if(strcmp(idd,del->ID)==0)
  366.         {
  367.             if(cou==1){
  368.                 NEW = NEW->link;
  369.                 del->link = NULL;
  370.                 free(del);
  371.                 xeicuteOrNot++;
  372.                 break;
  373.             }else{
  374.                 pre->link = del->link;
  375.                 del->link = NULL;
  376.                 free(del);
  377.                 xeicuteOrNot++;
  378.                 break;
  379.             }
  380.         }
  381.         cou++;
  382.         pre = del;
  383.         del = del->link;
  384.     }
  385.         if(xeicuteOrNot==0) return 1;
  386.         else return 2;
  387.     }
  388. ///.......................End of Delete Student travel history Function(after payment)...................
  389. ///.......................Select where student want to travel Function...................................
  390. void rootSelect()
  391. {
  392.     struct AdminRootAdd* tp = fst;
  393.     printf(" .....................................................................................................................\n");
  394.     printf(" 1.Home 2.Register New Student 3.Registered Student 4.Travel 5.Travel History 6. Delete History 7. Root Add 0.Sign Out\n");
  395.     printf(" .....................................................................................................................\n");
  396.     printf(" ..Travel..\n");
  397.     printf(" ..........\n");
  398.     printf(".........\n");
  399.     printf("Our root: \n");
  400.     printf("...........................................................................\n");
  401.         while(tp!=NULL){
  402.             printf(" %d. %s",tp->rootID,tp->rootname);
  403.             tp =tp->link;
  404.         }
  405.     printf("\n...........................................................................\n");
  406.     printf("\nSelect where to or from you start Travel : ");
  407.     scanf("%d",&rootSelct);
  408.     addRoot(rootSelct);
  409.     enteryourchoice();
  410. }
  411. void rootcreateAdim()
  412. {
  413.     rotID++;
  414.     struct AdminRootAdd* ad = (struct AdminRootAdd*)malloc(sizeof(struct AdminRootAdd));
  415.     printf("\nEnter root name : ");
  416.     scanf("%s",&ad->rootname);
  417.     printf("\nEnter root distance : ");
  418.     scanf("%f",&ad->dist);
  419.     printf("\nEnter root rent : ");
  420.     scanf("%d",&ad->rent);
  421.     ad->rootID = rotID;
  422.     ad->link = NULL;
  423.     if(fst==NULL){
  424.         fst = ad;
  425.         lst = ad;
  426.     }else{
  427.         lst->link = ad;
  428.         lst = ad;
  429.     }
  430.     enteryourchoice();
  431. }
  432. void firstAssignRoot()
  433. {
  434.     rotID++;
  435.     struct AdminRootAdd* dad = (struct AdminRootAdd*)malloc(sizeof(struct AdminRootAdd));
  436.     strcpy(dad->rootname,"Shamoli");
  437.     dad->dist=3.3;
  438.     dad->rent=10;
  439.     dad->rootID = rotID;
  440.     dad->link = NULL;
  441.     if(fst==NULL){
  442.         fst = dad;
  443.         lst = dad;
  444.     }else{
  445.         lst->link = dad;
  446.         lst = dad;
  447.     }
  448.  
  449. }
  450. void firstAssignRoot2()
  451. {
  452.     rotID++;
  453.     struct AdminRootAdd* dad = (struct AdminRootAdd*)malloc(sizeof(struct AdminRootAdd));
  454.     strcpy(dad->rootname,"Kallayanpur");
  455.     dad->dist=3.5;
  456.     dad->rent=15;
  457.     dad->rootID = rotID;
  458.     dad->link = NULL;
  459.     if(fst==NULL){
  460.         fst = dad;
  461.         lst = dad;
  462.     }else{
  463.         lst->link = dad;
  464.         lst = dad;
  465.     }
  466.  
  467. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement