Answer:
The program to this question can be given as:
Program:
#include <iostream> //header file
using namespace std; //using namespace
double MphAndMinutesToMiles(double milesPerHour, double minutesTraveled) //defining method
{
return (minutesTraveled/ 60.0)*milesPerHour; //return value.
}
int main() //defining main method
{
double milesPerHour,minutesTraveled; //define variable
cout<<"Enter miles per hour :";
cin >> milesPerHour;
cout<<"Enter travelling minutes :";
cin >> minutesTraveled;
cout << "Miles: "<< MphAndMinutesToMiles(milesPerHour, minutesTraveled)<< endl;
return 0;
}
Output:
Enter miles per hour :12
Enter travelling minutes :20
Miles: 4
Explanation:
The explanation of the above C++ program can be given as:
- In the first header file is include the function is define that is "MphAndMinutesToMiles". This function accepts two parameters that are "milesPerHour and minutesTraveled".
- Both parameter datatype is double and the function return type is also double. Inside a function calculate miles and return its value.
- In the main method, two variable defines that takes value from the user side and pass into the function. To print function return value we use "cout" function that prints function return value.