Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I tried completing it until the modification part (like on sample #1 and #2) but its not running correctly. PLEASE explain why its is wrong

I tried completing it until the modification part (like on sample #1 and #2) but its not running correctly. PLEASE explain why its is wrong and show me the correct way without using a For-loop or While-loop.
thank you so much!
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Problem C: Roller Coaster Design (coaster.c) (65 points) Every great theme park has a signature roller coaster. In designing a roller coaster, we must decide how many trains of cars need to be placed on the track. It turns out that no more than 25% of the track can be occupied with these trains to adhere to safety regulations. Thus, if the track is 1000 feet long, and a train is 42 feet long, then up to 5 trains can fit on the track. (To see this, note that 5 trains have a total length of 210 feet, and this value is 21%, less than or equal to 25%, of the total track length of 1000 feet. Note that 6 trains would take up 252 feet, or 25.2% of the track, which is too much.) In a train of cars, the first car is 10 feet lonng and all subsequent cars are 8 feet long. All cars seat up to 4 people. Since each of these values is constant, please use the following constants to store them: \#define FIRST CAR LENGTH 10 \#define NORMA L CAR LENGTH 8 \#define CAR_CAPACITY 4 For this program, the user will enter the total length of the track and the maximum length of the trains for the track. It is assumed that the trains formed will be as long as possible. For example, if the user enters 30 for the maximum length of the train, then the actual trains will have three cars and be of length 26 , since a four car train would exceed 30 feet. Your program should calculate the number of people that can be supported on the track at one time. (Note: It may be the case that more people can be supported by making a shorter train than possible, but for this particular assignment, maximize the size of each train.) Input Specification 1. The total length of the track will be a positive integer (in feet) less than 10000. 2. The maximum length of a train will be a positive integer in between 10 and 100 . Output Specification Output 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. Early Output Samples (later, Final outputs must look like Sample Runs 3 and 4) At first, two sample outputs of running the program are included below. Note that these samples are NOT a comprehensive test. You should test your program with different data than is shown here based on the specifications given above. Sample Run \#1 What is the total length of the track, in feet? 1000 What is the maximum length of a train, in feet? 42 Your ride can have at most 100 people on it at one time. (Note: Each train has 5 cars on it, and each car has 4 people, at most. Thus, 20 people can sit in one train. As previously established, 5 trains is the maximum for this track, so the maximum number of people this roller coaster can support is 100.) Sample Run \#2 What is the total length of the track, in feet? 1000 What is the maximum length of a train, in feet? 49 Your ride can have at most 100 people on it at one time. Now, modify what you have written to do: If the Maximum Length exceeds the Actual Length print a message that "Maximum Train Length has surplus of \%d feet" (and if no excess, print "Maximum Length fits exactly"); Now, modify what you have written to do: If the Maximum Length exceeds the Actual Length print a message that "Maximum Train Length has surplus of \%d feet" (and if no excess, print "Maximum Length fits exactly"); secondly, embed all of this (part C) code in a FOR loop that runs N times, where N is to be (prompted for and) read in at the beginning of the program. Thus, the user will input N and then will input the track_length and train_maximum N number of times. Given these new requirements, see Sample Runs \#3 and \#4. Your program must read the new input for the value of N, and must generate output similar to Sample Runs \#3 and \#4. What is the total length of the track, in feet? 1000 What is the maximum length of a train, in feet? 42 Your ride can have at most 100 people on it at one time. Maximum Length fits exactly What is the total length of the track, in feet? 1000 What is the maximum length of a train, in feet? 18 Your ride can have at most 104 people on it at one time. Maximum Length fits exactly Sample Run \#4 What is the value for N? 1 What is the total length of the track, in feet? 1000 What is the maximum length of a train, in feet? 59 Your ride can have at most 112 people on it at one time. Maximum Train Length has surplus of 1 feet Restrictions Although you may use other compilers, your program must compile and run using Codeblocks. Each of your three programs should include a header comment with the following information: your name, course number, section number, assignment title, and date. Also, make sure you include comments throughout your code describing the major steps in solving the problem. Grading Details Your programs will be graded upon the following criteria: 1) Your correctness 2) Your programming style and use of white space. Even if you have a plan and your program works perfectly, if your programming style is very poor or your use of white space is very poor, you could get 2% deducted from your grade. 3) Compatibility to Codeblocks. If your program does not compile in this environment, you will get a sizable deduction from your grade. make -s What is the total length of the track, in feet? 1000 What is the maximum length of a train, in feet? 42 Your ride can have at most 2051421140 people on tt at one time

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

What are the disadvantages of succession planning?

Answered: 1 week ago

Question

Explain Coulomb's law with an example

Answered: 1 week ago

Question

What is operating system?

Answered: 1 week ago

Question

What is Ohm's law and also tell about Snell's law?

Answered: 1 week ago