At a recent tortoise racing competition, your pet \"Speedy\" tookfirst place. Th
ID: 3608216 • Letter: A
Question
At a recent tortoise racing competition, your pet "Speedy" tookfirst place. The judges at the race determined that Speedy'saverage rate of travel is one foot every ten seconds. Justfor fun, you are curious how long it would take Speedy to travelfrom Cal Poly to Morro Bay (14 miles), to DisneyLand (232 miles),and around the world (24,901 miles). Write a program thatallows the user to enter these distances in miles and computesSpeedy's travel time for each one.Assumptions
Speedy's rate of travel is a constant within theprogram. The distances entered in miles will be positivewhole numbers. The output should be a decimal number in hours, withtwo decimal places. The program should display an appropriateprompting message, read the user's input from the keyboard, anddisplay the results on the screen with an explanatory remark. No checking is performed to see if the computations overflow themachine's allowable numeric range, and consequently invalid resultsmay occur.
Required Input
1. Three distances to walk (in miles).
Required Output
1. Prompts for input:
"Please enter the first distance for Speedy to travel (inmiles):"
"Please enter the second distance for Speedy to travel (inmiles):"
"Please enter the third distance for Speedy to travel (inmiles):"
2. An explanatory remark: "It would takeSpeedy _____ hours to travel ______ miles." printed for each result.
3. The number of hours (decimal number with 2decimal places).
4. The travel distance (same value as input).
Needed Constants and Formulas
Compute travel time ( Distance divided by rate)
Given: SpeedyRate = 1 ft / 10sec
1hour = 3600 sec
1mile = 5280 feet
anduser's input: Distance
formulas:
DistInFeet = Distance *5280
RateInFeet = 3600 *SpeedyRate
TravelTime = DistInFeet /RateInFeet
SPECIFICATIONS
1. Add the necessary program statements to create a completeprogram that solves the problem above:
2. Obtains the input data from the user and store it in a variableof type int. You may assume thatthe user will only enter whole numbers.
3. Write a function named FindTravelTime to perform allarithmetic calculations.
4. Invoke the function as appropriate from the main program to findthe travel time for each distance entered.
Explanation / Answer
please rate - thanks #include #include double FindTravelTime(int); int main() {int distance; double time; printf("Please enter the first distance for Speedy to travel (inmiles):"); scanf("%d",&distance); time=FindTravelTime(distance); printf( "It would take Speedy %.2f hours to travel %dmiles. ",time,distance); printf("Please enter the second distance for Speedy to travel (inmiles):"); scanf("%d",&distance); time=FindTravelTime(distance); printf( "It would take Speedy %.2f hours to travel %dmiles. ",time,distance); printf("Please enter the third distance for Speedy to travel (inmiles):"); scanf("%d",&distance); time=FindTravelTime(distance); printf( "It would take Speedy %.2f hours to travel %dmiles. ",time,distance); 14 2getch(); return 0; } double FindTravelTime(int distance) {double TravelTime,RateInFeet; int DistInFeet; double SpeedyRate=.1; //rate is .1 feet persecond DistInFeet=distance*5280; RateInFeet=3600*SpeedyRate; TravelTime=DistInFeet/RateInFeet; return TravelTime; }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.