Question: This is the C# program about the bus reservation system. Please add and edit the system to create FILE that can store all the data.
This is the C# program about the bus reservation system.
Please add and edit the system to create FILE that can store all the data.
PLEASE HELP ME. IT'S URGENT. I AM WAITING.
#include
/*********~~~~~~~~~~~~~STRUCTURES TO BE USED~~~~~~~~~~~************/
struct time { int iHrs,iMins;
};
struct bus { int iBusNum; int iBusCode; char chSeat[8][4][20]; char chDrivers_Name[20]; struct time stDeparture_Time, stArrival_Time; char chGoesTo[20]; char chGoesFrom[20]; float fFare; int iTicketSold; };
/*~~~~~~~~~~~~~~~~~~~~~~GLOBAL VARIABLES~~~~~~~~~~~~~~~~~~~~~~*/
char chEmpty[]="Empty";
static int iNumber=1; char i=':'; struct bus stBus[40];
/*~~~~~~~~~~~~~~~~~~~~~~FUNCTION PROTOTYPES~~~~~~~~~~~~~~~~~~~~~~*/
void fnNew_Bus(); void fnMainMenu(); void fnShowBuses(); void fnEmpty(); void fnSeatReservation(); void fnShowStatus(); void fnPrintLine(); void fnDailyReport();
/**************************************************************************** Function main PARAMETERS: no parameters.... Type void. Return type is also void. Entry point to the program. It calls the functions for Main Menu. ****************************************************************************/
void main() { fnMainMenu(); }
/*************************************************************************** FUNCTION DEFINITIONS ***************************************************************************/
/*~~~~~~~ FUNCTION fnMainMenu Parameters:void Return type:void Description:displays the main menu of the software.. allows the user to go to the desired screen..~~~~~~~*/
void fnMainMenu() { int iChoice; printf(" \t\t\t______________________"); printf(" \t\t\tBUS RESERVATION SYSTEM"); printf(" \t\t\t______________________ "); fnPrintLine(); /*Displaying the available choices : */
printf(" \t\t1.Bus Installation"); printf(" \t\t2.Bus reservation"); printf(" \t\t3.Show details"); printf(" \t\t4.Status"); printf(" \t\t5.Daily Report"); printf(" \t\t6.Exit"); printf(" \tEnter your choice as(1/2/3/4/5):-\t"); fflush(stdin); scanf("%d",&iChoice); /*Calling the appropriate functions to display the screen corresponding to the entered choice*/
switch(iChoice) { case 1 : //clrscr(); fnNew_Bus(); break; case 2: fnSeatReservation(); break;
case 3: fnShowBuses(); break; case 4: fnShowStatus(); break; case 5: fnDailyReport(); break; case 6: exit(0); default: printf("\t\t\tU have entered Wrong Choice!!!!"); getch(); fnMainMenu();
} }
/*~~~~~~~ FUNCTION fnNewBus Parameters: void Return type: void Description: This function is used to install the new bus in the system & add the relative information about the new bus ~~~~~~~*/
void fnNew_Bus()
{
char chChoice; printf(" \t\tEnter Information about bus "); do{ fnPrintLine(); printf(" \t\t Bus No:\t%d",iNumber); busC: printf(" \tEnter Bus Code:\t"); fflush(stdin); /*scanf("%d",&stBus[iNumber].iBusNum); if(stBus[iNumber].iBusNum==0) { printf(" \t\tInvalid Bus Number!!!!"); goto busN; }*/ stBus[iNumber].iBusNum=iNumber; scanf("%d",&stBus[iNumber].iBusCode); if(stBus[iNumber].iBusCode<1||stBus[iNumber].iBusCode>9999) { printf(" \t\tInvalid Bus Code!!!!"); goto busC; } /*if(strlen(stBus[iNumber].iBusCode)>20) { printf("Maximum 20 characters are allowed"); goto busC; }*/
dname: printf(" \tEnter driver's name:\t"); fflush(stdin); gets(stBus[iNumber].chDrivers_Name); // puts(stBus[iNumber].chDrivers_Name); if(strlen(stBus[iNumber].chDrivers_Name)>20) { printf("Maximum 20 characters are allowed"); goto dname; } artime: printf(" \tEnter arrival time:\t"); fflush(stdin); scanf("%d%c%d",&stBus[iNumber].stArrival_Time.iHrs,&i,&stBus[iNumber].stArrival_Time.iMins); if(stBus[iNumber].stArrival_Time.iHrs==0) { printf(" \t\tInvalid tTme!!!!"); goto artime; } //if((stBus[iNumber].stArrival_Time.iHrs>57)||(stBus[iNumber].stArrival_Time.iHrs<48)) //printf("invalid time"); if((i!=':')||(stBus[iNumber].stArrival_Time.iHrs>=24)||(stBus[iNumber].stArrival_Time.iHrs<0)||(stBus[iNumber].stArrival_Time.iMins>=60)||(stBus[iNumber].stArrival_Time.iMins<0)) { printf(" \t\tInvalid Time!!!! "); printf("\t\tEnter only--hh:mm!!!!"); goto artime; } deptime: printf(" \tEnter departure time:\t"); fflush(stdin); scanf("%d%c%d",&stBus[iNumber].stDeparture_Time.iHrs,&i,&stBus[iNumber].stDeparture_Time.iMins); if(stBus[iNumber].stDeparture_Time.iHrs==0) { printf("\t\tinvalid Time!!!!"); goto deptime; } if((i!=':')||(stBus[iNumber].stDeparture_Time.iHrs>=24)||(stBus[iNumber].stDeparture_Time.iHrs<0)||(stBus[iNumber].stDeparture_Time.iMins>=60)||(stBus[iNumber].stDeparture_Time.iMins<0)) { printf(" \t\tInvalid Time!!!!"); printf(" \t\tEnter only--hh:mm"); goto deptime; } from: printf(" \tFrom:\t"); fflush(stdin); gets(stBus[iNumber].chGoesFrom); if(strlen(stBus[iNumber].chGoesFrom)>20) { printf("Maximum 20 characters are allowed"); goto from; }
to: printf(" \tTo:\t"); fflush(stdin); gets(stBus[iNumber].chGoesTo); if(strlen(stBus[iNumber].chGoesTo)>20) { printf("Maximum 20 characters are allowed"); goto to; } printf(" \tFare:\t"); fflush(stdin); scanf("%f",&stBus[iNumber].fFare); stBus[iNumber].iTicketSold=0; printf(" "); fnEmpty(); fnPrintLine();
// printf("%s",stBus[iNumber].chGoesFrom); // printf("%s",stBus[iNumber].chGoesTo);
printf(" \tDo u want to continue to add information about new bus(y/n)?? "); fflush(stdin); scanf("%c",&chChoice); // printf("%c",chChoice);
iNumber++; //printf("%d",iNumber); }while(chChoice=='y'||chChoice=='Y'); fnMainMenu();
}
/*~~~~~~~ FUNCTION fnShowBuses Parameters: void Return type: void Description: This function has been used to show the details of buses which have been installed.~~~~~~~*/
void fnShowBuses() { int i1; printf(" \t\t\t______________________"); printf(" \t\t\t BUSES AVALAIBLE"); printf(" \t\t\t______________________ ");
for(i1=1;i1 } getch(); fnMainMenu(); } /*~~~~~~~ FUNCTION fnSeatReservation Parameters:void Return type:void Description:By using this function we can reserve any of the unreserved seatin a perticular bus ... .~~~~~~~*/ void fnSeatReservation() { //char arrSize[8][4]; char chName[20]; int iBusN; int iSeat; char chChoice; printf(" \t\t\t______________________"); printf(" \t\t\t ALLOTMENT"); printf(" \t\t\t______________________ "); fnPrintLine(); printf(" \t\tEnter the Bus Number-\t"); fflush(stdin); scanf("%d",&iBusN); if(iBusN>=iNumber) { printf(" \t\t\tSorry Bus Doesn,t Exist!!!!"); fnSeatReservation(); } seat: printf(" \t\tEnter the Seat number-\t"); fflush(stdin); scanf("%d",&iSeat); if(iSeat>32) { printf(" \t\tSorry!! There r only 32 seats in the bus!!!!") ; goto seat; } else if(strcmp(stBus[iBusN].chSeat[iSeat/4][(iSeat%4)-1],"Empty")==0) { printf(" \t\tEnter the passenger's name-\t"); name: fflush(stdin); gets(chName); if(strlen(chName)>20) { printf(" \t\tplz enter only 20 characters!!!!"); goto name; } else { strcpy(stBus[iBusN].chSeat[iSeat/4][iSeat%4-1],chName); printf(" \t\tYour seat is reserved now!!"); stBus[iBusN].iTicketSold++; printf(" \t do u want to continue with reservation(y/n)??"); fflush(stdin); chChoice=getchar(); if(chChoice=='y'||chChoice=='Y') fnSeatReservation(); else fnMainMenu(); } }else { printf(" \tThis seat is already reserved!!!!"); printf(" \t do u want to try again??"); fflush(stdin); chChoice=getchar(); if(chChoice=='y'||chChoice=='Y') fnSeatReservation(); else fnMainMenu(); } } void fnDailyReport() { int i; double dDailyTotal=0; double dBusTotal=0; printf(" \t\t\t______________________"); printf(" \t\t\t DAILY REPORT"); printf(" \t\t\t______________________ "); fnPrintLine(); for(i=1;i } printf(" \t\t\tDaily Total=\t%lf",dDailyTotal); getch(); fnMainMenu(); } /*~~~~~~~ FUNCTION empty Parameters:void Return type:void Description:This function is used to make empty all the seats in a new bus that is installed~~~~~~~~~~~~*/ void fnEmpty() { for(int i=0;i<8;i++) { for(int j=0;j<4;j++) { strcpy(stBus[iNumber].chSeat[i][j],chEmpty); } } } /*~~~~~~~ FUNCTION fnShowStatus Parameters:void Return type:void Description:displays the reservation status of a perticular bus entered by the user..~~~~~~~*/ void fnShowStatus() { int iBusN,index=0,j,k; char chChoice; printf(" \t\tEnter Bus no.-\t"); fflush(stdin); scanf("%d",&iBusN); if(iBusN>=iNumber) { printf(" \t\tBus doesn't Exist!!!!"); fnShowStatus(); } else { fnPrintLine(); printf(" Bus code-\t%d\t\tDriver's Name-\t%s",stBus[iBusN].iBusCode,stBus[iBusN].chDrivers_Name); printf(" Arrival Time-\t%d%c%d\t\tDeparture Time\t%d%c%d",stBus[iBusN].stArrival_Time.iHrs,i,stBus[iBusN].stArrival_Time.iMins,stBus[iBusN].stDeparture_Time.iHrs,i,stBus[iBusN].stDeparture_Time.iMins); printf(" From-\t\t%s\t\tTo-\t\t%s",stBus[iBusN].chGoesFrom,stBus[iBusN].chGoesTo); printf(" Fare-\t\t%f\tTickets Sold-\t%d",stBus[iBusN].fFare,stBus[iBusN].iTicketSold); printf(" "); fnPrintLine(); for(j=0;j<8;j++) { printf(" "); for(k=0;k<4;k++) { index++; printf("%d .%s\t",index,stBus[iBusN].chSeat[j][k]); } } } printf(" \t\tDo u want to continue with another bus(y/n)??"); fflush(stdin); chChoice=getchar(); if(chChoice=='y'||chChoice=='Y') fnShowStatus(); else fnMainMenu(); } /*~~~~~~~ FUNCTION menu Parameters:void Return type:void Description:This function is used to print a line of * for the purpose of separation.~~~~~~~*/ void fnPrintLine() { int j; for(j=0;j<60;j++) printf("*"); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
