Question: Write a program in C language where the output should consist of three lines. The first line outputs the maximum number of passengers on the

Write a program in C language where the output should consist of three lines. The first line outputs the maximum number of passengers on the roller coaster at any one time with a single statement of the following format:
Your ride can have at most X people on it at one time.
The second line should output the number of cars in the train that achieves this maximum with a single statement of the following format:
This can be achieved with trains of Y cars.
Note: If there are multiple ways in which the maximum number of people can be
supported, output the smallest number of cars that achieves this maximum. (Thus, if both 2 cars and 4 cars lead to 100 people on the ride and this is the maximum, then your program should output 2 cars.)
The third line should simply output the average value of people to length, as:
AVG Ratio: XXXX.XXX
Here is my code so far:
#include
#define FIRST_CAR_LENGTH 10
#define NORMAL_CAR_LENGTH 8
#define CAR_CAPACITY 4
int main(void){
int TRKlength, TRNlength, SafeTRK, passengers;
int SmallTrnAvail, TotSmallTrn, ActualTlength;
int CarsPerTRN, excessTRN, numTRN, totCars;
int i;
printf("What is the total length of the track in feet?
");
scanf("%d", &TRKlength);
SafeTRK = TRKlength*.25;
printf("What is the maximum length of a train in feet?
");
scanf("%d", &TRNlength);
SmallTrnAvail = TRNlength - FIRST_CAR_LENGTH;
TotSmallTrn = SmallTrnAvail / NORMAL_CAR_LENGTH;
ActualTlength = FIRST_CAR_LENGTH + NORMAL_CAR_LENGTH * TotSmallTrn;
CarsPerTRN =1+ TotSmallTrn;
numTRN = SafeTRK/ActualTlength;
totCars = numTRN * CarsPerTRN;
passengers = CAR_CAPACITY * totCars;
printf("Your ride can have at most %d people on it at one time
", passengers);
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!