#include #include #include long l_payment, l_interest; double old_balance= 1000.00, payment, new_balance; double principal, interest; void main() { payment = old_balance * (0.01/ (1.0 - pow(1.0/(1.01),12.0) ) ); cout << "paymetn before: " << payment << endl; cout.flags(ios::fixed); cout.precision(2); //l_payment = payment*100.00 + 0.5; //payment = l_payment; //payment = payment / 100.0; cout << setiosflags (ios::fixed | ios::showpoint); cout << "paymetn before: " << payment << endl; old_balance = 1000.00; for ( int i=1;i <= 12; i++) { interest = old_balance * 0.01; // l_interest = interest*100.00 + 0.5; // interest = l_interest; // interest = interest / 100.0; principal = payment - interest; new_balance = old_balance - principal; cout << old_balance << " " << interest << " " << principal << " " << new_balance << endl; old_balance = new_balance; } }