Answer this in C++ oating pont Create an application carch several car-pooling w
ID: 3871001 • Letter: A
Question
Answer this in C++
Explanation / Answer
// Method to calculate total cost
double costPerDay (double fuelCost, double toll, double parkFee)
{
double cost;
cost = toll + parkFee + fuelCost;
return cost;
}
//Method to calculate total number of gasoline required in a day
double gasolineNum(double totalMiles, double avg)
{
return (totalMiles/avg);
}
// Method to calculate cost of total gasoline required in a day
double gasolineCost(double numGasoline, double cost)
{
return (numGasoline * cost);
}
main()
{
double milesPerDay, costPerGasoline,avgMilesPerGasoline, parkingFee, tollFee, numofGasoline, costOfFuel,totalCost ;
/* *********** Take input from user ************ */
cout<<”Enter the input: Miles Per Day Cost per gasoline Avg miles per gasoline paring Fee Toll Fee”<<endl;
cin>> milesPerDay>>costPerGasoline>>avgMilesPerGasoline>> parkingFee>>tollFee;
numofGasoline = gasolineNum (milesPerDay, avgMilesPerGasoline);
costOfFuel = gasolineCost ( numofGasoline, costPerGasoline);
totalCost = costPerDay(costOfFuel, tollFee, parkingFee);
cout<<”Total cost per day: ”<<totalCost<<endl;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.