I have to do a simple program for school I was wondering if anyone can please to help me. I already created the program but it is not working properly and I have no idea how to fix it. Everything looks fine to me
Here's the assignment
Write a program that calculates the balance of a savings account at the end of a period of time. It should ask the user for the annual interest rate, the starting balance, and the number of months that have passed since the account was established. A loop should then iterate once for every month, performing the following:
A. Ask the user for the amount deposited into the account during the month (Do not accept negative numbers.) This amount should be added to the balance.
B. Ask the user for the amount withdrawn from the account during the month. (Do not accept negative number. Do not accept the amount if its is greater that the balance.) This amount should be subtracted from the balance.
C. Calculate the monthly interest and added to the balance.
THIS IS WHAT I HAVE DONE SO FAR:
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
double new_balance, ending_balance;
double interest_paid, annual_rate, principle_paid, payment;
cout << "Please enter the original loan amount $ (-1 to end the program):";
cin >> ending_balance;
cout << "Enter the interest rate on your loan %:";
cin >> annual_rate;
cout << endl;
// Setup a counter to count payments
int count = 1;
// Get the standard payment which is 1/20 of loan
payment = (ending_balance / 20.0);
while (ending_balance > 0.0) {
new_balance = ending_balance;
// Calculate interest by multiplying rate against balance
interest_paid = new_balance * (annual_rate / 12.0);
// Subtract interest from payment
principle_paid = payment - interest_paid;
// Subtract final payment from running balance
ending_balance = new_balance - principle_paid;
if ((new_balance + interest_paid) < payment) {
cout << count << ". Payment: $" << (new_balance + interest_paid) << " Interest: $" << interest_paid << " Principle: $" << (new_balance - interest_paid) << " Loan Balance is: $0.00" << endl;
}
else {
cout << count << ". Payment: $" << payment << " Interest: $" << interest_paid << " Principle: $" << principle_paid << " Loan Balance is: $" << ending_balance << endl;
}
count++;
}
system("pause");
return 0;
}
PLEASE SOMEBODY HELP ME!!!THANKS IN ADVANCE