(please run your program before submitted) Use double It is absolutely crucial t
ID: 3628611 • Letter: #
Question
(please run your program before submitted)Use double
It is absolutely crucial to end all of your programs with:
return 0;
as the last line before the closing '}' bracket in your main function.
Programs that do not follow this convention will not be graded correctly.
Programs that end with that line may still fail because they do not
generate the right output.
Each sample run is indicated by a line of "=" symbols. These lines only indicate
the start and the end of a sample run and should not be printed by
your program.
Use 64-bit floating point numbers (i.e., double) for all floating
point calculations. Do not use float as your results may differ from the test cases
due to small precision errors.
(ADD system ("pause"); and retunr 0; at the end)
Problem 5
#########
Runners have entered the mile race at the Penn Relays. Write
a program that scans in the race time in minutes and seconds for a
runner and computes and displays the speed in feet per seconds (fps)
and in meters per second (mps).
(Hints: There are 5,280 feet in one mile, and one kilometer equals
3,282 feet.)
Remarks: Please replicate the exact text of the prompts and the
output. Make sure that the answer is printed with two digit precision
(i.e., "%.2f" in printf). Even though the text must be the same, the
numbers may be different depending on the user input.
============= START OF SAMPLE RUN =======================
Enter the race time below.
Minutes: 3
Seconds: 52.83
The speed was 22.68 feet per second or 6.91 meters per second.
============= END OF SAMPLE RUN =======================
Explanation / Answer
// WORKING PERFECTLY .......
#include<stdio.h>
#include<stdlib.h>
int main()
{
double min,sec;
double fps,mps;
printf("============= START OF SAMPLE RUN ======================= ");
printf("Enter the race time below. Minutes: ");
scanf("%lf",&min);
printf(" Seconds ");
scanf("%lf",&sec);
fps = 5280 /(min*60+sec);
mps = (5280000)/(3282*(min*60+sec));
printf("The speed was %.2lf feet per second or %.2lf meters per second. ", fps,mps);
printf("============= END OF SAMPLE RUN =======================");
system ("pause");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.