1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
//Thomas Allicino 2/18/16
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
double MonthlyGasCost(double milesPerYear, double carMilesPerGallon, double gasCostPerGallon)
{
double gasCostPerMonth, milesPerMonth, gallonsPerMonth;
milesPerMonth == milesPerYear / 12;
gallonsPerMonth == milesPerMonth * carMilesPerGallon;
gasCostPerMonth == gallonsPerMonth * gasCostPerGallon;
return gasCostPerMonth;
}
double MonthlyMaintenanceCost(double mainYearAmt)
{
double mainCostPerMonth;
mainCostPerMonth == mainYearAmt / 12;
return mainCostPerMonth;
}
double MonthlyPremiumCost(double yearPremium)
{
double insCostPerMonth;
insCostPerMonth == yearPremium / 12;
return insCostPerMonth;
}
void TotalCostPerMonth(double gasCostPerMonth, double insCostPerMonth, double mainCostPerMonth, double totalCost)
{
totalCost == gasCostPerMonth + insCostPerMonth + mainCostPerMonth;
}
int main()
{
double milesPerYear, carMilesPerGallon, gasCostPerGallon, mainYearAmt, yearPremium;
double totalCost, mainCostPerMonth, insCostPerMonth, gasCostPerMonth;
ifstream infile;
infile.open("GasCosts.txt");
infile >> milesPerYear >> carMilesPerGallon >> gasCostPerGallon >> mainYearAmt >> yearPremium;
MonthlyGasCost(milesPerYear, carMilesPerGallon, gasCostPerGallon);
MonthlyMaintenanceCost(mainCostPerMonth);
MonthlyPremiumCost(insCostPerMonth);
TotalCostPerMonth(gasCostPerMonth, insCostPerMonth, mainCostPerMonth, totalCost);
}
|