Please answer in C only, not C++. Thanks. You are asked to write code to display the
Question:
Please answer in C only, not C++. Thanks.
You are asked to write code to display the total distance, average speed and total time taken by a car during a race. You will first take as input the distance of the track and the number of laps the car will make across the track. Now in a for loop take the input of the speed in each lap and then display the overall summary in the following format:
The number of laps column should be 10 characters in length, the others should be 20 characters in length. The data in all columns should be left-aligned. If the user enters a number that is less than or equal to zero for the number of laps, distance or speed, print an appropriate error message and ask the user to input the data again. The following is an example test case of the code:
Enter the number of laps
0
The value of number of laps must be positive and non zero
Enter the number of laps
2
Enter the distance of the lap
-9
The value of distance must be positive and non zero
Enter the distance of the lap
8
# of Laps Distance Speed Time
***********************************************************
Enter the speed of the car during lap 1:3
1 7.00 3.00 2.33
Enter the speed of the car during lap 2:5
2 7.00 5.00 1.40
Total: 14.00 9.00 3.73