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

Write the definition of a function named timeOnHighway that receives three param

ID: 3534212 • Letter: W

Question

Write the definition of a function named timeOnHighway that receives three parameters, all of type double: mileEndingPoint , mileStartingPoint , and speed . The first two parameters indicate the mile markers on an interstate at which a vehicle goes to and starts at; the third parameter indicates the speed of the vehicle in miles per hour. The function returns the number of hours it takes a vehicle to go from the starting mile marker to the ending one. The function has a default value for the speed: 55 miles per hour, and a default value for mileStartingPoint : 0.0.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Explanation / Answer

int Max(int iInput)

{

static int iHighest=0;

if (iInput>iHighest)

iHighest=iInput;

return iHighest;

}


The specification for the second one is incomplete, because it talks about having defaults for the starting point and speed, but it doesn't explain how the function is supposed to know when the defaults are to be applied:


double timeOnHighway(double mileEndingPoint, double mileStartingPoint, double speed)

{

return (mileEndingPoint-mileStartingPoint)/spee