problem with mortgage calculater

#include <cmath>
#include<iostream>
#include<iomanip>
using namespace std;
void inputFunction();
void calculateFunction();


int main()
{
inputFunction();

return 0;

}

void inputFunction(double principal, double rate, double term)
{
//get data from user
cout << "Enter your principal " << endl;
cin >> principal;
cout << "Enter your rate " << endl;
cin >> rate;
cout << "Enter your term" << endl;
cin >> term;

calculateFunction();
}

void calculateFunction(double principal, double rate, double term, double monthlyPayment)
{
//calculations

rate = rate / 1200.0;
term = term * 12;
monthlyPayment = principal*rate / (1.0 - pow(rate + 1, -term));

//print the output

cout << "Your monthlyPayment is " << setprecision(2) << monthlyPayment << endl;

}




that's my program, but at the beginning of the function it shows overload +1
just a beginner,and I have no idea how to fix it.
Any suggestion would be nice,thanks!
@winonav

You are calling the functions with no parameters, but your functions are expecting data.

In main(), you have..
 
inputFunction();


BUT the function is ..
void inputFunction(double principal, double rate, double term)
You haven't passed any of the variables it's expecting.

Same goes for your
void calculateFunction(double principal, double rate, double term, double monthlyPayment)
Last edited on
@whitenite1

But I need get parameters from user, right?
How should I put the parameters after the function call.
@winonav

You can get the values from the user in main(), then pass the values to the function to get the final answer..

Like this..
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 <cmath>
#include <iostream>
#include <iomanip>
using namespace std;


void calculateFunction(double principal, double rate, double term);


int main()
{
	double principal, rate, term;
	cout << "Enter your principal " << endl;
	cin >> principal;
	cout << "Enter your rate " << endl;
	cin >> rate;
	cout << "Enter your term" << endl;
	cin >> term;

	calculateFunction(principal, rate, term);
	return 0;

}

void calculateFunction(double principal, double rate, double term)
{
	//calculations
double monthlyPayment; // Have to first declare it, before it can be used
rate = rate / 1200.0;
term = term * 12;
monthlyPayment = principal*rate / (1.0 - pow(rate + 1, -term));

//print the output

cout << "Your monthlyPayment is " << setprecision(2) << monthlyPayment << endl;;
}


I'm not sure if you're getting the right results here, but it's a start.
Topic archived. No new replies allowed.