1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
My Menu code
#include <stdio.h>
void menu();
void busMenu();
void timePeriod();
int main()
{
printf("Welcome To The Bus Travel Viewer.\n");
printf("Press the RETURN key to continue....\n");
getchar();
menu();
return 0;
}
void menu()
{
char menu1choice;
char menu2choice;
char menu3choice;
char menu4choice;
char menu5choice;
printf("Bus Travel Viewer.\n");
printf("A:Buslist.\n");
printf("B:Display Daily Average Travel Time.\n");
printf("C:Display Predicted shortest travel time.\n");
printf("D:Display Longest/Shortest travel time for all time periods.\n");
printf("E:Display The Longest Time Taken To Reach Home.\n");
printf("Please select A,B,C,D or E.\n");
printf("Press the RETURN key to exit program.\n");
scanf("%c", &menu1choice);
switch ( menu1choice )
{
case 'A':
case'a':
{
char selection;
int time, timeHome;
printf("Please select your bus number from the following.\n");
printf("A:15.\n");
printf("B:27.\n");
printf("C:45.\n");
printf("D:46.\n");
scanf("%c,", &selection);
switch (selection)
{
case'A':
case'a':
printf("Please enter the current time period from 1pm-6:30pm with half-hour intervals.\n");
scanf("%d",&time);
timeHome=bus15Timings
default:printf("Sorry, you have input a wrong key.\n");
scanf("%c,", &selection);
break;
}
}
}
This is my database for my bus timings.
#include <stdio.h>
void main(void)
int bus15Timings [3][12] = { {1:00,1:30,2:00,2:30,3:00,3:30,4:00,4:30,5:00,5:30,6:00,6:30},//Time Period
{5,5,6,6,7,7,5,5,4,4,8,8},//bus15 waiting time
{8,8,9,9,7,7,7,8,8,20,20,20}//bus15 time taken to reach home
};
int bus27Timings [3][12] = { {1:00,1:30,2:00,2:30,3:00,3:30,4:00,4:30,5:00,5:30,6:00,6:30},//Timw Period
{8,8,7,7,6,6,4,4,6,6,5},//bus27 waiting time
{10,10,8,8,8,15,15,7,7,20,20,20}//bus27 time taken to reach home
};
int bus45Timings [3][12] = { {1:00,1:30,2:00,2:30,3:00,3:30,4:00,4:30,5:00,5:30,6:00,6:30},//Time Period
{10,10,8,8,10,12,9,6,7,4,4,3},//bus45 waiting time
{5,5,8,8,8,10,10,12,12,20,20,20}//bus45 time taken to reach home
};
int bus46Timings [3][12] = { {1:00,1:30,2:00,2:30,3:00,3:30,4:00,4:30,5:00,5:30,6:00,6:30},//Time Period
{12,8,8,5,5,3,2,5,8,10,6,5},//bus46 waiting time
{10,15,15,11,11,9,9,7,7,20,20,20}//bus46 time taken to reach home
};
|