×
Samples Blogs Make Payment About Us Reviews 4.9/5 Order Now

Bike Share Analysis in C++ assignment help

June 12, 2024
Professor Kevin Tan
Professor Kevin
🇸🇬 Singapore
C++
Professor Tan is an esteemed academic with a master's degree in computer science from the National University of Singapore. With over 900 completed orders, he is proficient in handling a wide range of C++ tests, from basic syntax to advanced template programming, ensuring students achieve exceptional results.
Key Topics
  • Longest and Shortest Route Code in C++
Tip of the day
Start assignments early to avoid last-minute stress and allocate time for debugging. Ensure you follow coding standards and document your code properly, as clarity and maintainability are crucial in software engineering.
News
In 2024, new programming tools like Elixir and PureScript are helping students build scalable systems and web apps, expanding their expertise in functional programming and concurrency.

Longest and Shortest Route Code in C++

You have been provided with a single day's record of all bike trips taken. Riders can be casual and they pay per ride or a registered rider who can make as many rides as they want. Each ride has a start station, and end station, time, and duration. The program created by our C++ assignment help experts finds the busiest time of day, the most popular station and least popular, and the longest and shortest trips.

Solution:

Source.cpp #include< stdio.h> #include< string.h> #include< stdlib.h> #include< fcntl.h> #include< unistd.h> #define BIKE_SIZE 4000 typedef struct Trip_struct { char membershipType[12]; int startStationId, endStationId, bikeId, duration, startHr, startMin; }Trip; typedef struct station_struct { int id; int count; // number of trips in a day }Station; typedef struct Bike_struct { char maintenanceFlag; int bikeId, endStationId; int numTrips, totalDuration; float totalMinutes; int startStationId; }Bike; void printMainMenu() { printf("Main menu:\n"); printf("\t1- Read Trip data\n"); printf("\t2- Run Metrics\n"); printf("\t3- Print Menu\n"); printf("\t4- Flag bikes for Maintenance\n"); printf("\t5- Update bike inventory\n"); printf("\t6- Quit\n"); printf("Enter Your choice: "); } void printMetricMenu() { printf("Metric menu:\n"); printf("\t1- Choose a metric to print\n"); printf("\t2- Return to main menu\n"); printf("Enter Your choice: "); } void printMetricSubMenu() { printf("Metric submenu:\n"); printf("\t1- Average number of trips per hour\n"); printf("\t2- The hour with largest number of trips\n"); printf("\t3- A report of the count of trips in each hour\n"); printf("\t4- Average duration of the trips (in both milliseconds and minutes)\n"); printf("\t5- The trip with the longest duration (in both milliseconds and minutes)\n"); printf("\t6- The 5 busiest starting stations (that had the largest number of trips in the day)\n"); printf("\t7- The 5 busiest ending stations (that had the largest number of trips in the day)\n"); printf("\t8- The percentage of trips in each membership type\n"); printf("\t9- The 10 bikes with the longest duration in minutes\n"); printf("\t10- The 10 bikes with the longest duration last station\n"); printf("\t11- The 10 bikes with the most trips\n"); printf("\t12- The bikes were used for 2 or less trips\n"); printf("\t13- ids and number of trips of the start station of the bikes were used for 2 or less trips\n"); printf("Enter Your choice: "); } void printPrintMenu() { printf("Print menu:\n"); printf("\t1- Print all trip data\n"); printf("\t2- Print all bike inventory\n"); printf("\t3- Print the CEO report\n"); printf("\t4- Print on Bike\n"); printf("\t5- Return to main menu\n"); printf("Enter Your choice: "); } int max(int x,int y) { if(x>y){ return x; } return y; } int tripComp(const void *p, const void *q) { int count1 = (*(const Trip*)p).bikeId; int count2 = (*(const Trip*)q).bikeId; return count1 - count2; } int greaterThan(int lhour, int lmin, int rhour, int rmin) { if (lhour > rhour) { return 1; } if (lhour < rhour) { return -1; } else { if (lmin > rmin) { return 1; } else if (lmin < rmin) { return -1; } } return 0; } void readTripData(char*filename,Trip **trips,int *n,Bike*bikes) { // preparing trip array FILE*f = fopen(filename, "r"); if (f == NULL) { printf("File does not exist.\n"); return; } fscanf(f,"%d", n); if (*trips != NULL) { free(*trips); } *trips =(Trip*) malloc((*n)*sizeof(Trip)); for (int i = 0; i < *n; i++) { fscanf(f,"%s %d %d %d %d %d %d", (*trips)[i].membershipType, &(*trips)[i].startStationId, &(*trips)[i].endStationId, &(*trips)[i].bikeId, &(*trips)[i].duration, &(*trips)[i].startHr, &(*trips)[i].startMin); } fclose(f); /// preparing bike array for (int i = 0; i < BIKE_SIZE; i++) { bikes[i].maintenanceFlag = 0; bikes[i].numTrips = 0; bikes[i].totalDuration = 0; bikes[i].totalMinutes = 0; bikes[i].bikeId = 0; } qsort((void*)(*trips), *n, sizeof(Trip), tripComp); int j = 0; bikes[j].bikeId = (*trips)[0].bikeId; for (int i = 0; i < *n; i++) { if (bikes[j].bikeId != (*trips)[i].bikeId) { j++; bikes[j].bikeId = (*trips)[i].bikeId; } } j = 0; int hour = -1,min = -1; int shour = 2e9, smin = 2e9; for (int i = 0; i < *n; i++) { if (bikes[j].bikeId != (*trips)[i].bikeId) { j++; hour = -1, min = -1; shour = 2e9, smin = 2e9; } bikes[j].numTrips++; bikes[j].totalDuration += (*trips)[i].duration; bikes[j].totalMinutes += (float)((*trips)[i].duration)/60000.0; if (greaterThan((*trips)[i].startHr, (*trips)[i].startMin, hour, min) > 0) { hour = (*trips)[i].startHr; min = (*trips)[i].startMin; bikes[j].endStationId = (*trips)[i].endStationId; } if (greaterThan(shour, smin, (*trips)[i].startHr, (*trips)[i].startMin) > 0) { shour = (*trips)[i].startHr; smin = (*trips)[i].startMin; bikes[j].startStationId = (*trips)[i].startStationId; } } } void averageTripPerHour(char* filename,Trip*trips,int size) { // TODO if (strcmp(filename, "none") == 0) { printf("The average trip per hour: %f\n", size/24.0); } else { FILE*f = fopen(filename, "w+"); if (f == NULL) { printf("File does not exist.\n"); return; } fprintf(f,"The average trip per hour: %f\n", size/24.0); fclose(f); } } void largestHourOfTrips(char* filename, Trip*trips, int size) { int hours[24] = { 0 }; int maxx = -1; int max_id = -1; for (int i = 0; i < size; i++) { hours[trips[i].startHr]++; if (hours[trips[i].startHr] > maxx) { maxx = hours[trips[i].startHr]; max_id = trips[i].startHr; } } if (strcmp(filename, "none") == 0) { printf("The hour with largest number of trips: %d\n", max_id); } else { FILE*f = fopen(filename, "w+"); if (f == NULL) { printf("File does not exist.\n"); return; } fprintf(f, "The hour with largest number of trips: %d\n", max_id); fclose(f); } } void reportTripsInHour(char* filename, Trip*trips, int size) { int hours[24] = { 0 }; for (int i = 0; i < size; i++) { hours[trips[i].startHr]++; } if (strcmp(filename, "none") == 0) { fprintf(stdout, "hour:number of trips\n"); for (int i = 0; i < 24; i++) { fprintf(stdout, "%4d:%d\n", i, hours[i]); } } else { FILE*f = fopen(filename, "w+"); if (f == NULL) { printf("File does not exist.\n"); return; } fprintf(f, "hour:number of trips\n"); for (int i = 0; i < 24; i++) { fprintf(f, "%d:%d\n", i, hours[i]); } fclose(f); } } void averageDurationOfTrips(char* filename, Trip*trips, int size) { double average = 0; for (int i = 0; i < size; i++) { average += trips[i].duration; } average /= (double)size; if (strcmp(filename, "none") == 0) { printf("The Average duration of the trips (in millisecs) : %f\n", average); printf("The Average duration of the trips (in seconds) : %f\n", average/(double)1000.0); } else { FILE*f = fopen(filename, "w+"); if (f == NULL) { printf("File does not exist.\n"); return; } fprintf(f,"The Average duration of the trips (in millisecs) : %f\n", average); fprintf(f,"The Average duration of the trips (in seconds) : %f\n", average / (double)1000.0); fclose(f); } } void getLongestTrip(char* filename, Trip*trips, int size) { double max_duration = -1; for (int i = 0; i < size; i++) { max_duration = max(max_duration, trips[i].duration); } if (strcmp(filename, "none") == 0) { printf("The trip with the longest duration (in millisecs) : %f\n", max_duration); printf("The trip with the longest duration (in seconds) : %f\n", max_duration / (double)1000.0); } else { FILE*f = fopen(filename, "w+"); if (f == NULL) { printf("File does not exist.\n"); return; } fprintf(f, "The Average duration of the trips (in millisecs) : %f\n", max_duration); fprintf(f, "the trip with the longest duration (in seconds) : %f\n", max_duration / (double)1000.0); fclose(f); } } int stationComp(const void *p, const void *q) { int count1 = (*(const Station*)p).count; int count2 = (*(const Station*)q).count; return count2 - count1; } void getFiveBusiestStart(char* filename, Trip* trips, int size) { Station *stations=(Station*) malloc(size * sizeof(Station)); Station empty; empty.id = empty.count = 0; for (int i = 0; i < size; i++) { stations[i] = empty; } for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { if (stations[j].id == 0) { stations[j].id = trips[i].startStationId; stations[j].count++; break; } else if (stations[j].id == trips[i].startStationId) { stations[j].count++; break; } } } qsort((void*)stations, size, sizeof(Station), stationComp); if (strcmp(filename, "none") == 0) { printf("The 5 busiest starting stations are:\n"); for (int i = 0; i < 5; i++) { printf("\t%d- id:%d, count:%d\n",i+1,stations[i].id,stations[i].count); } } else { FILE*f = fopen(filename, "w+"); if (f == NULL) { printf("File does not exist.\n"); return; } fprintf(f,"The 5 busiest starting stations are:\n"); for (int i = 0; i < 5; i++) { fprintf(f,"\t%d- id:%d, count:%d\n", i + 1, stations[i].id, stations[i].count); } fclose(f); } } void getFiveBusiestEnd(char* filename, Trip*trips, int size) { Station *stations = (Station*)malloc(size * sizeof(Station)); Station empty; empty.id = empty.count = 0; for (int i = 0; i < size; i++) { stations[i] = empty; } for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { if (stations[j].id == 0) { stations[j].id = trips[i].endStationId; stations[j].count++; break; } else if (stations[j].id == trips[i].endStationId) { stations[j].count++; break; } } } qsort((void*)stations, size, sizeof(Station), stationComp); if (strcmp(filename, "none") == 0) { printf("The 5 busiest ending stations are:\n"); for (int i = 0; i < 5; i++) { printf("\t%d- id:%d, count:%d\n", i + 1, stations[i].id, stations[i].count); } } else { FILE*f = fopen(filename, "w+"); if (f == NULL) { printf("File does not exist.\n"); return; } fprintf(f, "The 5 busiest ending stations are:\n"); for (int i = 0; i < 5; i++) { fprintf(f, "\t%d- id:%d, count:%d\n", i + 1, stations[i].id, stations[i].count); } fclose(f); } } void precentageInEachMembership(char * filename, Trip*trips, int size) { int causual = 0, registered = 0; for (int i = 0; i < size; i++) { if (trips[i].membershipType[0] == 'C') causual++; else registered++; } if (strcmp(filename, "none") == 0) { printf("The percentage of trips in Casual membership type: %f\n", (double)causual / (double)size); printf("The percentage of trips in Registered membership type: %f\n",(double)registered/(double)size); } else { FILE*f = fopen(filename, "w+"); if (f == NULL) { printf("File does not exist.\n"); return; } fprintf(f,"The percentage of trips in Casual membership type: %f\n", (double)causual / (double)size); fprintf(f,"The percentage of trips in Registered membership type: %f\n", (double)registered / (double)size); fclose(f); } } int bikeDurationComp(const void*a,const void*b) { return ((Bike*)b)->totalDuration - ((Bike*)a)->totalDuration; } void bike_longest10_Duration(char* filename,Bike* bikes) { qsort((void*)bikes, BIKE_SIZE, sizeof(Bike), bikeDurationComp); if (strcmp(filename, "none") == 0) { printf("Bikes with longest duration:\n ID:Duration\n"); for (int i = 0; i < 10; i++) { printf("%6d:%d\n", bikes[i].bikeId, bikes[i].totalDuration); } } else { FILE*f = fopen(filename, "w+"); if (f == NULL) { printf("File does not exist.\n"); return; } fprintf(f,"Bikes with longest duration:\n ID:Duration\n"); for (int i = 0; i < 10; i++) { fprintf(f,"%6d:%d\n", bikes[i].bikeId, bikes[i].totalDuration); } fclose(f); } } void bike_longest10_endStation(char*filename,Bike* bikes) { qsort((void*)bikes, BIKE_SIZE, sizeof(Bike), bikeDurationComp); if (strcmp(filename, "none") == 0) { printf("Bikes with longest duration:\n ID:End Station\n"); for (int i = 0; i < 10; i++) { printf("%6d:%d\n", bikes[i].bikeId, bikes[i].endStationId); } } else { FILE*f = fopen(filename, "w+"); if (f == NULL) { printf("File does not exist.\n"); return; } fprintf(f, "Bikes with longest duration:\n ID:End Station\n"); for (int i = 0; i < 10; i++) { fprintf(f, "%6d:%d\n", bikes[i].bikeId, bikes[i].endStationId); } fclose(f); } } int bikeTripsComp(const void*a, const void*b) { return ((Bike*)b)->numTrips- ((Bike*)a)->numTrips; } void bike_most10_trips(char*filename,Bike* bikes) { qsort((void*)bikes, BIKE_SIZE, sizeof(Bike), bikeTripsComp); if (strcmp(filename, "none") == 0) { printf("Top 10 Bikes in number of trips:\n ID:Number of trips\n"); for (int i = 0; i < 10; i++) { printf("%6d:%d\n", bikes[i].bikeId, bikes[i].numTrips); } } else { FILE*f = fopen(filename, "w+"); if (f == NULL) { printf("File does not exist.\n"); return; } fprintf(f, "Bikes with longest duration:\n ID:Number of trips\n"); for (int i = 0; i < 10; i++) { fprintf(f, "%6d:%d\n", bikes[i].bikeId, bikes[i].numTrips); } fclose(f); } } void bike_less2_trips(char* filename,Bike* bikes) { qsort((void*)bikes, BIKE_SIZE, sizeof(Bike), bikeTripsComp); int i = BIKE_SIZE-1; while (bikes[i--].bikeId == 0); if (strcmp(filename, "none") == 0) { printf("Bikes with less than or equal to two rides:\n ID:Number of trips\n"); for (; i >= 0; i--) { if (bikes[i].numTrips <= 2) { printf("%6d:%d\n", bikes[i].bikeId, bikes[i].numTrips); } } } else { FILE*f = fopen(filename, "w+"); if (f == NULL) { printf("File does not exist.\n"); return; } fprintf(f,"Bikes with longest duration:\n ID:Number of trips\n"); for (; i >= 0; i--) { if (bikes[i].numTrips <= 2) { fprintf(f,"%6d:%d\n", bikes[i].bikeId, bikes[i].numTrips); } } } } int intComp(const void *a, const void *b) { return *((int*)a) - *((int*)b); } int numberOfTrips(int stationId, Trip* trips,int size) { int cnt = 0; for (int i = 0; i < size; i++) { if (trips[i].startStationId == stationId) { cnt++; } } return cnt; } void bike_less2_startStation_and_trips_number(char*filename,Bike* bikes,Trip*trips,int size) { qsort((void*)bikes, BIKE_SIZE, sizeof(Bike), bikeTripsComp); int i = BIKE_SIZE - 1; int j = 0; int stations[BIKE_SIZE]; memset(stations, -1 , BIKE_SIZE*sizeof(int)); while (bikes[i--].bikeId == 0); for (; i >= 0; i--) { if (bikes[i].numTrips <= 2) { stations[j++] = bikes[i].startStationId; } } qsort(stations, BIKE_SIZE, sizeof(int),intComp); if (strcmp(filename, "none") == 0) { printf("Start stations of bikes with less than or equal to two trips\nStart Station ID:Number of trips\n"); for (int i = 0; i < BIKE_SIZE; i++) { if (stations[i] == -1) { continue; } if (i > 0 && stations[i] == stations[i - 1]) { continue; } printf("%d:%d\n", stations[i], numberOfTrips(stations[i],trips,size)); } } else { FILE*f = fopen(filename, "w+"); if (f == NULL) { printf("File does not exist.\n"); return; } fprintf(f,"Start Station ID:Number of trips\n"); for (int i = 0; i < BIKE_SIZE; i++) { if (stations[i] == 2e10) { break; } if (i > 0 && stations[i] == stations[i - 1]) { continue; } fprintf(f,"%d:%d\n", stations[i], numberOfTrips(stations[i],trips,size)); } } } void printAllTripData(char *filename,Trip*trips,int size) { if (strcmp(filename, "none") == 0) { for (int i = 0; i < size; i++) { printf("%s %d %d %d %d %d %d\n", trips[i].membershipType, trips[i].startStationId, trips[i].endStationId, trips[i].bikeId, trips[i].duration, trips[i].startHr, trips[i].startMin); } } else { FILE*f = fopen(filename, "w+"); if (f == NULL) { printf("File does not exist.\n"); return; } for (int i = 0; i < size; i++) { fprintf(f, "%s %d %d %d %d %d %d\n", trips[i].membershipType, trips[i].startStationId, trips[i].endStationId, trips[i].bikeId, trips[i].duration, trips[i].startHr, trips[i].startMin); } } } void printAllBikeInventory(char *filename, Bike* bike) { if (strcmp(filename, "none") == 0) { for (int i = 0; i < BIKE_SIZE; i++) { if (bike[i].bikeId != 0) { printf("%c %d %d %d %d %d\n", bike[i].maintenanceFlag, bike[i].bikeId, bike[i].startStationId , bike[i].endStationId, bike[i].totalDuration, bike[i].numTrips); } } } else { FILE*f = fopen(filename, "w+"); if (f == NULL) { printf("File does not exist.\n"); return; } for (int i = 0; i < BIKE_SIZE; i++) { if (bike[i].bikeId != 0) { fprintf(f, "%c %d %d %d %d %d\n", bike[i].maintenanceFlag, bike[i].bikeId, bike[i].startStationId , bike[i].endStationId, bike[i].totalDuration, bike[i].numTrips); } } } } void printCEOReport(char *filename,Trip*trips,int size,Bike*bikes) { int out, save_out; int x= 0; if (strcmp(filename, "none") != 0) { out = open(filename, O_RDWR | O_CREAT | O_APPEND, 0600); save_out = dup(fileno(stdout)); dup2(out, fileno(stdout)); filename = "none"; x=1; } averageTripPerHour(filename, trips, size); printf("----------------------------------------------------------\n"); largestHourOfTrips(filename, trips, size); printf("----------------------------------------------------------\n"); printf("Reporting trip per hour:\n"); reportTripsInHour(filename, trips, size); printf("----------------------------------------------------------\n"); averageDurationOfTrips(filename, trips, size); printf("----------------------------------------------------------\n"); getLongestTrip(filename,trips,size); printf("----------------------------------------------------------\n"); getFiveBusiestStart(filename, trips, size); printf("----------------------------------------------------------\n"); getFiveBusiestEnd(filename, trips, size); printf("----------------------------------------------------------\n"); precentageInEachMembership(filename, trips, size); printf("----------------------------------------------------------\n"); bike_longest10_Duration(filename, bikes); printf("----------------------------------------------------------\n"); bike_longest10_endStation(filename, bikes); printf("----------------------------------------------------------\n"); bike_most10_trips(filename, bikes); printf("----------------------------------------------------------\n"); bike_less2_trips(filename, bikes); printf("----------------------------------------------------------\n"); bike_less2_startStation_and_trips_number(filename, bikes, trips, size); printf("----------------------------------------------------------\n"); if (x==1) { fflush(stdout); dup2(save_out,fileno(stdout)); //close(out); close(save_out); } } void printABike(char *filename,Bike*bikes,int id) { if (strcmp(filename, "none") == 0) { for (int i = 0; i < BIKE_SIZE; i++) { if (bikes[i].bikeId == id) { printf("%c %d %d %d %d %d\n", bikes[i].maintenanceFlag, bikes[i].bikeId, bikes[i].startStationId , bikes[i].endStationId, bikes[i].totalDuration, bikes[i].numTrips); break; } } } else { FILE*f = fopen(filename, "w+"); if (f == NULL) { printf("File does not exist.\n"); return; } for (int i = 0; i < BIKE_SIZE; i++) { if (bikes[i].bikeId == id) { printf("%c %d %d %d %d %d\n", bikes[i].maintenanceFlag, bikes[i].bikeId, bikes[i].startStationId , bikes[i].endStationId, bikes[i].totalDuration, bikes[i].numTrips); break; } } } } void flagBikesForMaintainance(Bike*bikes) { qsort((void*)bikes, BIKE_SIZE, sizeof(Bike), bikeDurationComp); for (int i = 0; i < 10; i++) { bikes[i].maintenanceFlag = 1; } printf("The 10 longest duration bike's maintainance flag has been set to true"); } void deleteBike(Bike*bikes,int id,int emptyId) { bikes[id] = bikes[emptyId - 1] ; Bike empty; empty.bikeId = 0; empty.endStationId = 0; empty.maintenanceFlag = 0; empty.numTrips = 0; empty.startStationId = 0; empty.totalDuration = 0; empty.totalMinutes = 0; bikes[emptyId - 1] = empty; } void updateBikeInventory(Bike*bikes) { int choice; int emptyId = -1; int id; do { printf("Enter 1 if you need to add a bike 2 for delete: "); scanf("%d", &choice); } while (choice != 1 && choice != 2); switch (choice) { case 1: for (int i = 0; i < BIKE_SIZE; i++) { if (bikes[i].bikeId == 0) { emptyId = i; break; } } printf("Enter id: "); scanf("%d",&bikes[emptyId].bikeId); bikes[emptyId].endStationId = 0; bikes[emptyId].startStationId = 0; printf("Enter start station id"); break; case 2: printf("Enter the id to delete: "); scanf("%d", &choice); for (int i = 0; i < BIKE_SIZE; i++) { if (bikes[i].bikeId == choice) { id = i; } if (bikes[i].bikeId == 0) { emptyId = i; break; } } deleteBike(bikes, id,emptyId); break; } } int main() { int choice; int exit = 0; char filename[50]; Trip* trips = NULL; int tripsSize = 0; Bike bikes[BIKE_SIZE]; int bikeId; while (!exit) { printMainMenu(); scanf("%d", &choice); switch (choice) { case 1: printf("Enter filename for reading: "); scanf("%s", filename); readTripData(filename,&trips,&tripsSize,bikes); break; case 2: while (!exit) { printMetricMenu(); scanf("%d", &choice); switch (choice) { case 1: printMetricSubMenu(); scanf("%d", &choice); switch (choice){ case 1: printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); averageTripPerHour(filename,trips,tripsSize); break; case 2: printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); largestHourOfTrips(filename,trips, tripsSize); break; case 3: printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); reportTripsInHour(filename, trips, tripsSize); break; case 4: printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); averageDurationOfTrips(filename, trips, tripsSize); break; case 5: printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); getLongestTrip(filename, trips, tripsSize); break; case 6: printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); getFiveBusiestStart(filename, trips, tripsSize); break; case 7: printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); getFiveBusiestEnd(filename, trips, tripsSize); break; case 8: printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); precentageInEachMembership(filename, trips, tripsSize); break; case 9: printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); bike_longest10_Duration(filename,bikes); break; case 10: printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); bike_longest10_endStation(filename,bikes); break; case 11: printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); bike_most10_trips(filename,bikes); break; case 12: printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); bike_less2_trips(filename, bikes); break; case 13: printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); bike_less2_startStation_and_trips_number(filename,bikes,trips,tripsSize); break; } break; case 2: exit = 1; break; } } exit = 0; break; case 3: while (!exit) { printPrintMenu(); scanf("%d", &choice); switch (choice) { case 1: printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); printAllTripData(filename,trips,tripsSize); break; case 2: printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); printAllBikeInventory(filename,bikes); break; case 3: printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); printCEOReport(filename,trips,tripsSize,bikes); break; case 4: printf("Enter the bike id: "); scanf("%d", &bikeId); printf("Enter filename for printing(\"none\" for stdout): "); scanf("%s", filename); printABike(filename,bikes,bikeId); break; case 5: exit = 1; break; } } exit = 0; break; case 4: flagBikesForMaintainance(bikes); break; case 5: updateBikeInventory(bikes); break; case 6: exit = 1; break; } } free(trips); }

Similar services

Check out our diverse range of programming homework samples to see the high-quality work we provide. Each sample demonstrates our expertise in handling various programming tasks and languages. Let these examples give you confidence in our ability to assist with your programming assignments effectively and efficiently.