I need my code to display Month but it seems my code is skipping month's and not displaying 1, 2 3. It's going 1 , 3 ,5 and so on. This is the code i have for it `int month = 1;` and later on the code i have month++ That's my first mistake and i'm not sure how to possibly fix it. My second mistake is my Interest Paid output. This is the code i have for it `interestPaid = loanBalance*i;` This is on the while loop, but i'm not sure why it's not displaying the correct amount. It should display for month 1 = 500.00 , Month 2 = 498.28 and Month 3 = 496.55 and so on... However my code display's something close to it, but not that. i is my monthly interest rate. My code for it seems to be fine. If i can fix this two things i'll be able to finish the project. This is my entire code, someone please help me finish it and tell me how i can fix it so that my month is displayed in 1, 2, 3, etc.... and not 1, 3, 5, etc... And why my interest is not displaying what my professor has on his output screen (i provided the first three months on top in bold) If i can fix those things i'll have the rest. Here's my entire code

#include <iostream>
#include <iomanip>

using namespace std;
int main ( )

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103`` ``````{ int month = 1; // Holds the user's amount of loan. double loanAmount; // Holds the user's interest rate. double i; // Holds the user's yearly Interest Rate. double interestRate; // Holds the user's interest paid every month. double interestPaid; // "n" means the months it will take the user to pay off the loan. double n; // Holds the variable for total months. double years; // Holds payment data. double monthlyPayment; // Holds the user Principle paid. double principlePaid; // Holds the user Loan balance. double loanBalance; // Asks the user to input how much money they took out. cout<<"Enter loan amount ->"; cin>>loanAmount; // Asks the user to input their interest rate. cout<<"Enter interest rate -->"; cin>>interestRate; i = (interestRate/1200); // Asks the user to input the number of years they are taking the loan for. cout<<"Enter number of years of the laon ->"; cin>>years; n = years*12; // Equation that determines the user's monthly payment. monthlyPayment = loanAmount*(i/(1-pow(1+i,-n))); // Equation for interest paid every month. interestPaid = loanAmount*i; // Equation for Principle paid. principlePaid = monthlyPayment-interestPaid; // Equation for Loan Balance loanBalance = loanAmount-principlePaid; cout<<"Month"<<"\t"<<"Payment"<<"\t"<<"Interest Paid"<<"\t"<<"Principle Paid"<<"\t"<<"Loan Balance"<0); cin.get ( ); cin.get ( ); return 0; }``````
Last edited on
Topic archived. No new replies allowed.