Four track stars entered the mile race the Penn Relays. Write a program that wil
ID: 3623306 • Letter: F
Question
Four track stars entered the mile race the Penn Relays. Write a program that will read the last name and the race time in minutes and seconds for one runner and compute and print the speed in feet per second and in meters per second after the runner's name. (Hints: There are 5280 feet in one mile, and one kilometer equals 3281 feet; one meter is equal to 3.281 feet) Test you programs on each of the times below.
Name Minutes Seconds
Deavers 3 52.83
Jackson 3 59.83
Write and call a function that displays instructions to the program user. Write two other functions, one to compute the speed in meters per second and the other to compute the speed in feet per second.
Explanation / Answer
please rate - thanks
hope this is good
#include <iostream>
using namespace std;
void instructions();
double tofeet(double);
double tometers(double);
int main()
{string name;
int min,i;
double fps,mps,sec,seconds;
instructions();
for(i=0;i<4;i++)
{cout<<"Enter name: ";
cin>>name;
cout<<"Enter race time ";
cout<<"minutes: ";
cin>>min;
cout<<"seconds: ";
cin>>sec;
seconds=min*60+sec;
fps=tofeet(seconds);
mps=tometers(fps);
cout<<name<<" ran the race in "<<min<<" minutes "<<sec<<" seconds =";
cout<<fps<<" feet per sec="<<mps<<" meters per second ";
}
system("pause");
return 0;
}
void instructions()
{cout<<"Four track stars entered the mile race the Penn Relays. ";
cout<<"This program will read the last name and the race time ";
cout<<"in minutes and seconds for one runner and compute and print ";
cout<<"the speed in feet per second and in meters per second after ";
cout<<"the runner's name. ";
}
double tofeet(double s)
{return 5280./s;
}
double tometers(double s)
{return s*.3048;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.