Problem with inputing numbers

Hello, this is my first time taking a programming class and I started with C++ at my local community college, unfortunately I seem to have run into a problem in the third project and for the life of me I can't figure out.

The problem is that no matter what I input it returns a ridiculous number that isn't even possible. I'm assuming I am doing something wrong with inputting the numbers into the function, I'm not entirely sure however, any help is appreciated.

The code is from an amortization problem in which we are supposed to create a library with three different functions which return the following:

1. returns the amount of each monthly payment
2. which returns the amount of the entire loan
3. which returns the number of monthly payments to be made

Below here the the code for this function:
1
2
3
4
5
6
7
8
double getPaymentAmount(int numberOfMonths, double amountOfLoan, double yearlyInterest)
	{
		double monthlyInterest = 0;
		double paymentAmount = 0;
		monthlyInterest = yearlyInterest / MONTHLY;
		paymentAmount = ((pow((1 + monthlyInterest), numberOfMonths)) /       ((pow((1 + monthlyInterest), numberOfMonths)) - 1)) * amountOfLoan * monthlyInterest;
		return paymentAmount;
	}


and this is the code for calling up the numbers that go into the function:
1
2
3
4
5
6
7
8
9
10
                        case '1':
			puts("Please enter the amount of Months:");
			scanf("%d", &numberOfMonths);
			puts("Please enter the amount of Loan:");
			scanf("%f", &amountOfLoan);
			puts("Please enter the Annual Interest Rate:");
			scanf("%f", &yearlyInterestRate);
			printf("%f", getPaymentAmount(&numberOfMonths,  &amountOfLoan, &yearlyInterestRate));
			getchar();
			break;


The format is wrong, use "%lf" for double
Topic archived. No new replies allowed.