Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 cars and cars lead to people on the ride and this is the maximum, then your program should output cars.
The third line should simply output the average value of people to length, as:
AVG Ratio: XXXXXXX
Here is my code so far:
#include
#define FIRSTCARLENGTH
#define NORMALCARLENGTH
#define CARCAPACITY
int mainvoid
int TRKlength, TRNlength, SafeTRK, passengers;
int SmallTrnAvail, TotSmallTrn, ActualTlength;
int CarsPerTRN, excessTRN, numTRN, totCars;
int i;
printfWhat is the total length of the track in feet?
;
scanfd &TRKlength;
SafeTRK TRKlength;
printfWhat is the maximum length of a train in feet?
;
scanfd &TRNlength;
SmallTrnAvail TRNlength FIRSTCARLENGTH;
TotSmallTrn SmallTrnAvail NORMALCARLENGTH;
ActualTlength FIRSTCARLENGTH NORMALCARLENGTH TotSmallTrn;
CarsPerTRN TotSmallTrn;
numTRN SafeTRKActualTlength;
totCars numTRN CarsPerTRN;
passengers CARCAPACITY totCars;
printfYour ride can have at most d people on it at one time
passengers;
return ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started