#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
#include <cstdio>
#include <math.h>
#include <iostream>
using std::fixed;
#include <iomanip>
using std::setprecision;
using namespace std;
double computeInterest(double dollars, int rate);
//returns the calculated interest.
void printEarning(double dollars, double interest);
//Displays the result.
int main()
{
double dollars, amount, interest, power, formularate;
int years, rate;
char response;
bool notValid;
int a=1;
bool Repeat();
while(1);
{
cout << fixed << setprecision( 2 );
do{
notValid=false;
cout << "\nEnter the Principal Value:" ;
cin >> dollars;
if (dollars <10 || dollars >100000)
{
cout << "\nYou have entered invalid data";
notValid=true;
}
} while (notValid);
do {
notValid=false;
cout << "\nEnter the Interest Rate (in %):" ;
cin >> rate;
if (rate <.1 || rate > 99)
{
cout << "\nYou have entered invalid data";
notValid=true;
}
} while (notValid);
do {
notValid=false;
cout << "\nEnter the time period (in years):" ;
cin >> years;
if (years<1 || years>100)
{
cout << "\nYou have entered invalid data";
notValid=true;
}
} while (notValid);
{
notValid=false;
cout << "\n\nYear Beginning Balance Interest Earned Ending Balance";
cout << "\n------ ----------------- --------------- ---------------\n";
for(a==1; a <= years;)
{
formularate=(rate/100.0);
amount = dollars * pow(1 + (formularate), (a) );
interest+=(amount-dollars);
cout << a;
cout << " ";
cout << ((dollars));
cout << " ";
cout << interest;
cout << " ";
cout << amount;
cout << " ";
cout <<"\n\n";
a++;
}
cout << "Do you want to continue? (y/n) ";
cin>>response;
if ((response == 'N' || response == 'n'))
return 0;
if ((response == 'Y' || response == 'y'))
{
}
}
}
system("pause");
return 0;
}
This post has been edited by jimblumberg: 07 October 2012 - 08:07 PM
Reason for edit:: Added missing Code Tags, Please learn to use them.

New Topic/Question
Reply



MultiQuote





|