Answer to Question #328589 in C++ for Program Training

Question #328589

Write a function so that the main() code below can be replaced by the simpler code that calls function MphAndMinutesToMiles(). Original main(): 


int main() {
   double milesPerHour;
   double minutesTraveled;
   double hoursTraveled;
   double milesTraveled;

   cin >> milesPerHour;
   cin >> minutesTraveled;

   hoursTraveled = minutesTraveled / 60.0;
   milesTraveled = hoursTraveled * milesPerHour;

   cout << "Miles: " << milesTraveled << endl;

   return 0;
}
1
Expert's answer
2022-04-14T06:16:40-0400
#include <iostream>

using namespace std;

void MphAndMinutesToMiles(double milesPerHour, double minutesTraveled)
{
	cout << "Miles: " << (minutesTraveled / 60.0)*milesPerHour;
}

void main()
{
	double milesPerHour;
	double minutesTraveled;
	cout << "Please, enter milesPerHour and minutesTraveled: ";
	cin >> milesPerHour >> minutesTraveled;
	MphAndMinutesToMiles(milesPerHour, minutesTraveled);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS