Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CS 140 Treadmill or Marathon Conceptse Function Overloading and Parameters HW03-

ID: 3723547 • Letter: C

Question

CS 140 Treadmill or Marathon Conceptse Function Overloading and Parameters HW03-35 points Name: Due Date: You would like to know how fast you can run in miles per hour. Your treadmill will tell your speed in terms of a pace (minutes and seconds per mile such as a "5:30 mile") or in terms of kilometers per hour (kph). The same thing happens in a marathon. Write an overloaded function convertToMPH. The first definition should take as input one two integers that represent the pace in minutes and seconds and return the speed in miles per hour (mph) as a double. The second definition should take as in input one double that represents the speed in kph and return the speed in mph as a double. One mile is approximately 1.61 kilometers. You will need to write a driver program in main to test your function. Have the user input the following values. Input: Output: 8, 21 12.321 10, 53 18, 37 17.112

Explanation / Answer

------------------------------------ans.cpp---------------------------------------------------

#include<bits/stdc++.h>

using namespace std;

double convertToMPH(int min, int sec){

double total = min*60 + sec;

double mph = 3600/total;

return mph;

}

double convertToMPH(double kph ){

double mph = kph/1.61;

return mph;

}

int main(){

double ans ;

cout << fixed;

cout << setprecision(2);

cout<<convertToMPH(8,21)<<endl;

cout<<convertToMPH(12.321)<<endl;

cout<<convertToMPH(10,53)<<endl;

cout<<convertToMPH(18,37)<<endl;

cout<<convertToMPH(17.112)<<endl;

return 0;

}

----------------------------------------------------end----------------------------------------------------------