![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2005
Posts: 1
Rep Power: 0
![]() |
Scrolling off the screen
I have been assigned to create a loan schedule in C++, with longer term loans to not scroll of the screen I have completed the loan schedule but utterly stumped on the prevention of longer term loans to not go off the screen. What I'd like to have happen is to have the output in 12 month chunks.
Here is my code if that helps: #include <iostream> #include <cstdlib> #include <cmath> #include <iomanip> using namespace std; int main() { char again; do { int n, m; double p, a, r, i, c; cout << "Please enter the loan in dollars: "; cin >> p; // Loan Amount = p cout << "Please the annual interest rate in percent: "; cin >> a; // Interest Rate = a cout << "Please the number of installments in months: "; cin >> n; // Months of the Loan = n i = 0.01 * a / 12; //i = 0.01 times Interest Rate divided by 12 r = (i * p / (1 - (1 / (pow((1 + i),n))))); // r = calculates the Monthy Re-Payment cout.setf(ios::fixed); cout << endl << "THE MONTHLY RE-PAYMENT IS = " << setprecision(2) << r << endl <<endl; // Output of the Monthly Re-Payment cout << "Month Interest Paid Loan Repaid Outstanding Loan" << endl; cout << "-----------------------------------------------------" << endl; m = 1; c = p; while (m <= n) { cout << setprecision(2) << setw(4) << m << setw(15) << (c*i) << setw(14) << (r - c*i) << setw(18) << abs(c - (r - c*i)) << endl; c = (c - (r - c*i)); m++; } cout << "----------------------------------------------------" << endl; //Output of the schedule cout << "Again?"; cin >> again; } while (again == 'y' || again == 'Y'); // Loops back with either upper or lowercase (Y or y) return 0; } Last edited by 70jwprz; Mar 21st, 2005 at 12:21 PM. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|