Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 21st, 2005, 12:12 PM   #1
70jwprz
Newbie
 
70jwprz's Avatar
 
Join Date: Mar 2005
Posts: 1
Rep Power: 0 70jwprz is on a distinguished road
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.
70jwprz is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:50 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC