Error Code




#include<iostream>
#include<math>
#include<iomanip>
using namespace std;
double getPayment(int,double,int);
int main()
{
int carPrice=0,rebate=0,term=0;
double creditRate=0.0,dealerRate=0.0,creditPayment=0.0,dealerPayment=0.0;
cout << "car price:";
cin >> carPrice;
cout << "Rebate:";
cin >> rebate;
cout << "Credit Union rate:";
cin >> creditRate;
cout << "Dealer rate:";
cin >> dealerRate;
cout << "terms in years:";
cin >> term;
creditPayment=getPayment(carPrice-rebate,creditRate/12,term*12);
dealerPayment=getPayment(carPrice-rebate,dealerRate/12,term*12);
cout << fixed <<-setprecision(2) << endl;
cout << "Credit union payment: $" << creditPayment <<endl;
cout << "Total Pay under Credit Union is :" << creditPayment*12*term+reabte <<endl;
cout << "Dealer payment :$ " << dealerPayment << endl;
cout << "Total Pay under Dealer rate is :" << dealerPayment*12*term+rebate <<endl;
return 0;
}
double getPayment(int prin,double monthRate,int months)
{
double monthPay=0.0;
if(1-pow(monthRate+!,-months) ==0 )
return -1;
monthPay=prin * monthRate / (1- pow(monthRate +1 ,-months));
return monthPay;
}

error C1083: Cannot open include file: math: no such file or directory
IntelliSense: cannot open source file "math"
IntelliSense:no operator "-" mathese these operands


Can someone help me debug this program
Changes are commented

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
#include<iostream>
#include<cmath> //<-- changed to cmath
#include<iomanip>
using namespace std;
double getPayment(int, double, int);
int main()
{
	int carPrice = 0, rebate = 0, term = 0;
	double creditRate = 0.0, dealerRate = 0.0, creditPayment = 0.0, dealerPayment = 0.0;
	cout << "car price:";
	cin >> carPrice;
	cout << "Rebate:";
	cin >> rebate;
	cout << "Credit Union rate:";
	cin >> creditRate;
	cout << "Dealer rate:";
	cin >> dealerRate;
	cout << "terms in years:";
	cin >> term;
	creditPayment = getPayment(carPrice - rebate, creditRate / 12, term * 12);
	dealerPayment = getPayment(carPrice - rebate, dealerRate / 12, term * 12);
	cout << fixed << setprecision(2) << endl; //<-- removed the dash
	cout << "Credit union payment: $" << creditPayment << endl;
	cout << "Total Pay under Credit Union is :" << creditPayment * 12 * term + rebate << endl; //<-- fixed rebate
	cout << "Dealer payment :$ " << dealerPayment << endl;
	cout << "Total Pay under Dealer rate is :" << dealerPayment * 12 * term + rebate << endl;
	return 0;
}
double getPayment(int prin, double monthRate, int months)
{
	double monthPay = 0.0;
	if (1 - pow(monthRate + 1, -months) == 0) //<--  changed ! to 1
		return -1;
	monthPay = prin * monthRate / (1 - pow(monthRate + 1, -months));
	return monthPay;
}
Topic archived. No new replies allowed.