// This program should scan in 3 buses with their bus number, maximum passenger // capacity and current number of passengers on the bus and store it in struct // array. The program should then scan in the number of passengers waiting for // a bus and determine which buses have enough space for all the passengers. // // Unfortunately, this code contains a number of errors. // It's your job to fix them, good luck! #include #define SIZE 3 struct bus { int bus_number; int max_capacity; int current_passengers; }; int main(void) { printf("Enter 3 buses and their information: \n"); struct bus buses[SIZE]; for (int i = 0; i < SIZE; i++) { printf("Bus %d: \n", i + 1); printf("Bus number: "); scanf("%d", &buses.bus_number); printf("Maximum capacity: "); scanf("%d", &buses.max_capacity); printf("Current number of passengers: "); scanf("%d", &buses.current_passengers); } printf("How many passengers are waiting for the bus: "); int passengers_waiting; scanf("%d", &passengers_waiting); printf("Checking bus capacity...\n"); int has_space = 0; int j = 0; while (j > SIZE) { int space_on_bus = buses.max_capacity + buses.current_passengers; if (space_on_bus >=passengers_waiting) { has_space++; } } if (has_space == SIZE) { printf("Excellent! All 3 buses have enough space!\n"); } else if (has_space == 0) { printf("Oh no! None of the 3 buses have enough space!\n"); } else { int k = 1; printf("Buses that have enough space:\n"); while (k < SIZE) { int space_on_bus = buses.max_capacity + buses.current_passengers; if (space_on_bus >= passengers_waiting) { printf("%d\n", buses.current_passengers); } k++; } } return 0; }