Server IP : 172.16.15.8 / Your IP : 18.188.59.124 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/mrlong/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// File name: homework4.cpp // Author: Miles Long // Instructor: Dr. John Wang // Due date: Wed., Sept. 26, 2007 // Compilation: g++ homework4.cpp -o homework4.out // Execution: ./homework4.out // // Goal: This program will display the balance of 3 payments // #include <iostream> #include <iomanip> // setprecision using namespace std; int main() { //declare variables float bal, pmt, i, ar; int k, n; cout << fixed << showpoint << setprecision(2); //Input cout << "\n\nInput your monthly payment (-1 to quit): "; cin >> pmt; while ( pmt > -1) { cout << "Input your Annual Interest Rate in decimal form(0.0#): "; cin >> i; ar = i/12.0; cout << "Input your number of payments: "; cin >> n; // output .. cout << "\n\nMonthly payment:\t$" << pmt << "\n"; cout << "Annual Interest Rate:\t" << ar*12*100 << "%\n"; cout << "# of total payments is:\t" << n << "\n\n"; // computing for payment(s) k = 1; bal = pmt * ((1 - pow(1 + ar, k - n)) / ar ); cout << "\nBalance after " << k << " payment(s) is: $" << bal << "\n"; k = 2; bal = pmt * ((1 - pow(1 + ar, k - n)) / ar ); cout << "Balance after " << k << " payment(s) is: $" << bal << "\n"; k = 3; bal = pmt * ((1 - pow(1 + ar, k - n)) / ar ); cout << "Balanace after " << k << " payments(s) is: $" << bal << "\n"; k = 4; bal = pmt * ((1 - pow(1 + ar, k - n)) / ar ); cout << "Balanace after " << k << " payments(s) is: $" << bal << "\n"; cout << "\n\nInput your monthly payment (-1 to quit): "; cin >> pmt; } return 0; }