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;} #include <iostream>using namespace std;//please right your answer here.int main() {double milesPerHour;double minutesTraveled;cin >> milesPerHour;cin >> minutesTraveled;cout << "Miles: " << MphAndMinutesToMiles(milesPerHour, minutesTraveled) << endl;return 0;} Please help me with this problem using C++.

Question
Asked Nov 9, 2019
272 views

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;
}
 

#include <iostream>
using namespace std;

//please right your answer here.

int main() {
double milesPerHour;
double minutesTraveled;

cin >> milesPerHour;
cin >> minutesTraveled;

cout << "Miles: " << MphAndMinutesToMiles(milesPerHour, minutesTraveled) << endl;

return 0;
}

 
Please help me with this problem using C++.
check_circle

Expert Answer

Step 1

Program:

#include <iostream>
using namespace std;

double MphAndMinutesToMiles(double milesPerHour, double minutesTraveled)
{
return (minutesTraveled / 60.0) * milesPerHour;
}

int main()
{

double milesPerHour;
double minutesTraveled;

cin >> milesPerHour;
cin >> minutesTraveled;

cout << "Miles: " << MphAndMinutesToMiles(milesPerHour, minutesTraveled) << endl;

return0;
}
 
Step 2

Screenshot:

...
help_outline

Image Transcriptionclose

#include <iostream> using namespace std double MphAndMinutesToMiles (double milesPerHour, double minutesTraveled) return (minutesTraveled 60.e) milesPerHour; int main) double miles PerHour; double minutesTraveled; cin milesPerHour; cin minutesTraveled; MphAndMinutesToMiles (milesPerHour, minutesTraveled) << endl; cout <<"Miles: return 0;

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: Suppose that a maximum flow network contains a node, other than the source node, without incoming ar...

A: Maximum flow problem:“Yes”, it is possible if the maximum flow network does not contain source node ...

question_answer

Q: First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ...

A: Create a JAVA file named IncomeTax.Ask the user to enter income and marital status.Based on marital ...

question_answer

Q: in python  Given a nested list named table, use nested loops to print each element in the nested lis...

A: Create a PYTHON program to print all “table” (list) element with respect to there first, second and ...

question_answer

Q: How do I write 1 cup = 8 ounces and then use that to find the total ounces of milk- 2cups +  flour 2...

A: 1 cup is equal to 8 ounces.The total cup is given as 2-cups of milk, 2.66 cups of flour, and 1.5 cup...

question_answer

Q: Create a program that prompts the user for an amount less than 100 and then displays the minimum num...

A: Program AlgorithmInitialize the required variables.Get the input from the user and check if the inpu...

question_answer

Q: Output in C++

A: C++ PROGRAM:#include &lt;iostream&gt;void mystery(int x[], int n) {int temp; for(int i=0; i&lt;n / 2...

question_answer

Q: Business example: Precision Tools sells a line of high-quality woodworking tools. When customers pla...

A: Context diagram:The Context Diagram shows the system being viewed as a single high-level entity and ...

question_answer

Q: Odd man out: . Topological sort Algorithm DFS Algorithm Binary search Algorithm BFS Algorithm Prim's...

A: Answer:Binary Search AlgorithmExplanation:Topological sort Algorithm, DFS algorithm, BFS algorithm a...

question_answer

Q: What is the forensic recovery process for files on a solid state drive?

A: Forensic recovery process is different from the other recovery processes, but it might produce the r...