Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The program calculates and displays the car expenses: Monthly car payment: Month

ID: 3629044 • Letter: T

Question

The program calculates and displays the car expenses:
Monthly car payment:
Monthly fuel cost (city):
Monthly fuel cost (highway):
Monthly insurance cost:
Total car expenses

This is what I have so far:

//Ketrisa Foley

#include <iostream>
#include <iomanip>

using namespace std;

int main ()
{
double high_FuelCost;
double high_miles = 400;
double city_FuelCost;
double city_miles = 600;
double MPG = 3.50;
double carInsurance;
double carLoan;
double carPayment;
double numbPayments = 60;
double rate = .001;
double totalExpenses;

//Calculate the highway and city fuel cost.
high_FuelCost = (high_miles/12) * MPG;
city_FuelCost = (city_miles/12) * MPG;

//Calculate the car payment.
payment = rate * (1 + rate)^60 / ((1 + rate)^60 - 1) * Loan amount (which is 20000)
return 0;
}

My problem is to calculate the car payment, the loan amount has to be calculated with the formula, which I don't know how to in C++ language. Also, the program has to be generic.

Explanation / Answer

please rate - thanks

are you sure the rate is correct. .001 is only 1.2% a year

//Ketrisa Foley

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main ()
{
double high_FuelCost;
double high_miles = 400;
double city_FuelCost;
double city_miles = 600;
double MPG = 3.50;
double carInsurance;
double carLoan;
double carPayment;
double numbPayments = 60;
double rate = .001;
double totalExpenses;
double LoanAmount=20000;

//Calculate the highway and city fuel cost.
high_FuelCost = (high_miles/12) * MPG;
city_FuelCost = (city_miles/12) * MPG;

//Calculate the car payment.
carPayment = LoanAmount*(rate/(1.-pow((1+rate),-60)));
cout<<"Monthly payment="<<carPayment <<endl;
system("pause");
return 0;
}