Skip to content

Instantly share code, notes, and snippets.

@0xMurage
Created January 27, 2017 14:11
Show Gist options
  • Save 0xMurage/34a7c8cae417c551efb3969649b26420 to your computer and use it in GitHub Desktop.
Save 0xMurage/34a7c8cae417c551efb3969649b26420 to your computer and use it in GitHub Desktop.
A C bus company program demo
#include "stdio.h"
int
buses[30], revenue[30],
collections[30], fuel_collections[30],
total_buses=0, total_workers, total_income=0,
total_fuel=0, profit, salary, distance [50],
choice, routes;
char location[50], regist[50], name[50], number_plate[30];
main(){
printf(" Skynet Shuttle Company \n");
printf(" Email: skynetcomms.com \n");
printf(" \n\n\n\n********MENU***********\n\n");
printf(" 1. Registration \n");
printf(" 2. Exit\n");
printf("\n \t\t Enter your choice\n");
scanf("%d", &choice);
switch (choice)
{
case 1:
{
printf("\tnew data input\n\n");
printf("Enter the first name ");
scanf("%s", &name);
printf("\nwelcome %s to Skynet Shuttle company \n", name);
printf("\nEnter the number of routes \t");
scanf("%d", &routes);
for (int y=0; y<routes; y++){
printf("\n*************Route 00%d***********\n",y);
printf("\nEnter the destination and depature of route00%d\n ",y);
scanf("%s", &location[y]);
printf("\nEnter the distance of the route 00%d in KM\n",y);
scanf("%d", &distance[routes]);
printf("How many company buses using route 00%d ?\t", y);
scanf("%d", buses[y]);
for(int x=0; x<buses[y]; x++){
printf("Bus %d\n", x);
printf("Enter the registration number of the bus %d",x);
scanf("%s", &number_plate[x]);
printf("Enter the total money collected today by the %s ", x);
scanf("%d", &collections[x]);
printf("Enter the amount spnt on fuel for bus %s", x);
scanf("%d", &fuel_collections);
for(int h=0; h<buses[y];h++){
revenue [ y]=collections [x] - fuel_collections[x];
printf("the toal revenue %d is %d",y, revenue[y] );
for(int i=0; i<buses[y]; i++) {
total_income=total_income+collections[i];
total_fuel=total_fuel+fuel_collections[i];
profit=total_income- total_fuel;
}
}
for(int b=0; b<=routes; b++){
total_buses=total_buses+buses[b];
total_workers=total_buses*2;
printf("total buses= %d\n", total_buses);
printf("the total workers= %d\n", total_workers);
printf(" the total collections = %d\n", total_income);
printf("total fuel expense = %d\n ", total_fuel);
printf("remaining amount = %d\n", profit);
salary=0.4*profit;
printf("salary = %d\n", salary);
int large=revenue[0];
for (int i= 1; i<routes; i++){
if (revenue[i]>large){
large=revenue[i];
}
}
printf("The bus which had the highest profit made Ksh %d \n", large);
int small=revenue [0];
for (int i=1; i<routes; i++){
if (revenue[i]<small){
small=revenue[i];
}
}
printf("The bus which made the least profit made Ksh %d\n", small);
}
break;
}
}
}
case 2:
{
printf("Thank you .............The program is exiting...\n");
break;
}
default:
printf("invalid menu choice selection \t...program is terminating.....\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment