Menu

Coral Please Write Function Drivingcost Parameters Drivenmiles Milespergallon Dollarsperga Q43800359

CORAL please.

Write a function DrivingCost with parameters drivenMiles,milesPerGallon, and dollarsPerGallon, that returns the dollar costto drive those miles. All items are of type float.

Ex: If the function is called with 50 20.0 3.1599, the functionreturns 7.89975.

Define that function in a program whose inputs are the car’smiles/gallon and the gas dollars/gallon (both floats). Output thegas cost for 10 miles, 50 miles, and 400 miles, by calling yourDrivingCost function three times.

Ex: If the input is 20.0 3.1599, the output is:

1.57995 7.89975 63.198

Note: Small expression differences can yield smallfloating-point output differences due to computer rounding. Ex: (a+ b)/3.0 is the same as a/3.0 + b/3.0 but output may differslightly. Because our system tests programs by comparing output,please obey the following when writing your expression for thisproblem. In the DrivingCost function, use the variables in thefollowing order to calculate the cost: drivenMiles, milesPerGallon,dollarsPerGallon.

Expert Answer


Answer to CORAL please. Write a function DrivingCost with parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that retur…

OR