Hey all, completely new to all of this and really needed some help on my one assignment.
Assignment: Write a program that asks for a loan amount, the number of years, and the annual interest rate. Use a function, CalcPayment to calculate the payment to amortize the loan, then return the value to main.
double CalcPayment (double loan, interestRate, time, payment, years, interest)
{
time = years * 12;
interestRate = interest * .01;
CalcPayment = (loan (interestRate (1 + interestRate) pow (time))) / ((1 + interestRate) pow (time) - 1)
return CalcPayment;
}
int main ()
{
double a, b, c, d;
a = CalcPayment;
b = loan;
c = years;
d = interest;
cout << "Enter the loan amount: " << endl;
cin >> b;
cout << "Enter the number of years: " << endl;
cin >> c;
cout << "Enter the annual interest rate: " << endl;
cin >> d;
cout << "Payment is " << a << endl;
}
I don't understand, so many "not declared". I'm very very very new to this...
#include <iostream>
usingnamespace std;
main(){
// declare your variables to allocate memory space
double loanAmount, annualInterest; // declare double's to accept decimal numbers
int years; // declare an int to accept a whole integer
// ask the user to input the loan amount
cout << "Loan amount: ";
cin >> loanAmount;
// ask the user to input the number of years
cout << "Number of years: ";
cin >> years;
// ask the user to input the number of years
cout << "Annual Interest Rate: ";
cin >> annualInterest;
// Calculate all of it and print it to screen
cout << endl;
cout << "Your total payment is: " << loanAmount + (loanAmount * (annualInterest/100)) * years << endl;
cout << "Good Bye..." << endl;
system("pause");
}