Code:

```
/* Name: ME
COSC: 150
Program: prog1
Due Date: Sept. 7, 2006 */
/* Program Trip:
This program calculates the total cost and miles per gallon
of a vehicle, based on the miles traveled, fuel consumed,
fuel cost per gallon, and operating cost per mile.
Input: The total cost, miles traveled, total fuel consumed,
unit cost of the fuel, and operating cost per mile.
Output: The miles per gallon, total cost of the trip,
and the cost per mile. */
/* Variable Dictionary:
Miles: Total Miles Traveled
Fuel: Total gallons used
UnitFeulCost: Feul cost per gallon
UnitOperCost: Operating cost per mile
MPG: Miles per gallon
TFeulCost: Total feul cost
TOperCost: Total operating cost
TTripCost: Total trip cost
CostPerMile: Cost per mile */
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
void main()
{
clrscr();
double
Miles, Fuel, UnitFuelCost, UnitOperCost, MPG, TFuelCost, TOperCost,
TTripCost, CostPerMile;
ofstream outfile;
outfile.open("c:result.dat");
//Read in the total miles and fuel
cout<<"enter the miles traveled and the gallons of fuel used "<<endl;
cin>>Miles>>Fuel;
//Calculate miles per gallon
MPG = Miles / Fuel;
//Read in the fuel cost per gallon
//and operating cost per mile.
cout<<"enter the fuel cost and operating cost "<<endl;
cin>>UnitFuelCost>>UnitOperCost;
//Calculate the total fuel cost, operating
//cost, trip cost, and cost per mile.
TFuelCost = Fuel * UnitFuelCost;
TOperCost = UnitOperCost * Miles;
TTripCost = TFuelCost + TOperCost;
CostPerMile = TTripCost / Miles;
//Print the outputs
outfile<<"\n Miles Per Gallon: "<<MPG;
outfile<<"\n Total Trip Cost: $ "<<TTripCost;
outfile<<"\n Cost Per Mile: $ "<<CostPerMile;
outfile.close();
getch();
}
```