Computer Science and Programming - Fall 2009

 

Lab. 11 [Maximum points – 30]

 

For demonstration and submission by end of the lab.

 

Write a C++ program that will provide a user with the time it takes, the amount of gas needed, and the cost of the gas required to travel a certain distance. Your program must use the following two functions:

 

(a). A function time_for_journey that takes as input the distance in miles to be covered and the speed in mph; and returns the time in hours.

 

(b). A function gas that takes as input the mileage in miles per gallon, the distance in miles to be covered, and the cost per gallon of gas; and calculates the amount of gas, and the total cost of gas required.

 

Your program should prompt the user for the appropriate input.