In my effort to become a software developer, I am faced with the project (more likely than not simple to the experience) where I must determine the monthly payment of a loan
Obviously to determine the monthly payment, the equation is :
rate*(1+rate)^n
----------------------------------*L
((1+rate)^n-1)
rate = the monthly interest
n = # of payments
l = loan amount
I am stumped as how to include the exponent into the code. obviously cmath is to be used:
let me give you what i have done, it is actually not much, as none of the MATH has actually been done:
-----------Code:#include <cmath> #include <cstdio> #include <iostream> using namespace std; int main () { int loan; // Loan amount taken out int payments; // Number of payments as well as exponent int interest; // monthly interest rate int result; // monthly payment bool notValid; cout <<"Use this program to"; cout <<"determine monthly interest - enter loan amount\n"; do { notValid =false; cin>>loan; if (loan < 10 || loan> 999999) { cout <<"\n The loan amount must"; cout <<"be between $10 and $999,999.99"; notValid=true; } }while (notValid); cout <<"\n Enter number of monthly payments:"; do { notValid =false; cin>>payments; if (payments < 10 || payments> 360) { cout <<"\n The monthly payments must"; cout <<"be between 12 and 360 months"; notValid=true; } }while (notValid); }
All i have included are two of the inital equations ( I still have to ask how much the interest is, which isnt a problem) and the validation problem aka making sure the user inputs are between the specificed range.
Im not asking for this to be written for me, obviously I have to do that - which I want to - i want to learn the process of how this is done, and maybe if there is a more efficent way to doing this. Also note that this is a structed programming intro course to C, so for any explanations - please try to keep it in those terms.
I also have to present this information back to the user, but Im pretty sure how to do that. Any help would be great
thanks in advance
you can respond here or my aim is chikkennn