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.

LANGUAGE: C++

CHALLENGE:

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.

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,

4 Comments

  1. Andrea on April 5, 2015 at 10:58 pm

    Closing parenthesis is missing after 55.

    • Cidney on September 19, 2015 at 5:04 pm

      Andrea, you the real MVP.

  2. Josh on April 21, 2016 at 6:24 pm

    double timeOnHighway (double mileEndingPoint, double mileStartingPoint = 0.0, double speed = 55.0)
    {
    return (mileEndingPoint – mileStartingPoint) / speed;
    }

  3. Mistica on November 17, 2016 at 10:37 am

    double timeOnHighway (double mileEndingPoint, double
    mileStartingPoint = 0.0, double speed = 55.0)
    {
    return (mileEndingPoint – mileStartingPoint) / speed;
    }

Leave a Comment

You must be logged in to post a comment.