Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The code should be written and worked out in C programming language only. In this homework you will write a running race simulator. Each athlete
The code should be written and worked out in C programming language only.
In this homework you will write a running race simulator. Each athlete has acceleration (m/s) and top speed (m/s) attributes. In this program you will enter attributes for two athletes and the race length (in meters) and you will determine the winner of the race. Assume that the race is long enough to reach top speed for both athletes. The things you should do in this assignment is listed below: 1. Main function: a. Get the length of the race from the user in meters. (Integer) b. Get information of athlete 1 and athlete 2 from the user. c. Acceleration and top speed values are float. d. In this function you will print the winner of the race. e. In the main function, you can only call findWinner function. f. All the printf and scanf operations will be performed in the main function. There will be no input and output operations in the other functions 2. calculate Acceleration Time: a. This function calculates and returns the time in seconds) needed for an athlete to reach top speed. b. It takes 2 input parameters: i. Acceleration of athlete ii. Top speed of athlete C. Return a float value 3. calculate DistanceAccelerating: a. This function calculates and returns the distance (in meters) covered by an athlete until reaching top speed. b. It takes 2 input parameters: i. Acceleration of athlete ii. Acceleration time C. Return a float value. d. Hint: Use the formula d = za 4. calculate Time TopSpeed: a. This function calculates and returns the time (in seconds) needed for an athlete to finish the race after reaching top speed. b. It takes 2 input parameters: i. Top speed of athlete ii. Remaining distance after reaching top speed C. Return a float value. 5. findWinner: a. This function finds and returns the winner of the race. b. It takes 5 input parameters: i. Race length ii. Acceleration and top speed of athlete 1 iii. Acceleration and top speed of athlete 2 C. Calculates the total time spent by both athletes to finish the race. Use calculateAcceleration Time, calculate DistanceAccelerating and calculateTime Top Speed functions for both athletes with proper parameters in order to calculate the total time for both athletes. d. Return 1 if the athlete 1 is the winner, return 2 if the athlete 2 is the winner, return O if both athletes finish the race at the same time. SUBMISSION Submit your file with the given format below: name_surname.c Do not use letters specific to turkish in the file name. EXAMPLE gokhan@DESKTOP-28ALSUE:/mnt/c/Users/gokha/OneDrive/Desktop/cse114$ ./a.out Enter the length of the race: 100 Enter the acceleration of athlete 1: 3.1 Enter the top speed of athlete 1: 12.2 Enter the acceleration of athlete 2: 2.5 Enter the top speed of athlete 2: 12.5 Winner is athlete 1 gokhan@DESKTOP-28ALSUE:/mnt/c/Users/gokha/OneDrive/Desktop/cse114$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