Thursday, August 15, 2013

Bank Change Rates


Code:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;




//named constants
const double KENDALL_INTEREST_RATE=0.0108;
const double CG_INTEREST_RATE=0.0210;
const double HOMESTEAD_INTEREST_RATE=0.0222;
const double HIALEAH_INTEREST_RATE=0.0425;


const double NA=1.0; //annually.
const double NQ=4.0;//quartelly.
const double NM=12.0;//monthly.
const double ND=365.0;//daily.
const double T=5.0;
int main()
{
 //declare variables.
 double principal;
    double amount;
 double interest;

 //declare statement.
 cout<<"Please insert the amount you want to invest:"<<endl;
 cin>>principal;
 cout<<endl;

 //calculate amount for Bank of Kendall.
 amount = principal * pow(1.0 +  KENDALL_INTEREST_RATE/NQ, NQ*T);
 //calculate the invesment interest
 interest = amount - principal;

  //display results for Bank of Kendall.
cout << fixed << showpoint;
cout << setprecision(2);
cout<<right;
cout<<setw(5)<<"Bank "<<"             "<<setw(10)<<"Interest"<<"  "<<setw(10)<<"Times"<<"  "<<setw(15)<<"Principal"<<"  "<<setw(10)<<"Interest"<<setw(10)<<"Total"<<endl;
cout<<setw(5)<<"Name "<<"             "<<setw(10)<<"Rate(%)"  <<"  "<<setw(15)<<"Compounded"<< setw(35)<<"Amount"<<'\n' /*<<endl*/;
cout<<setfill('-')<< setw(20)<<" "<< setw(14)<<"     "<< setw(15)<<"   "<< setw(14)<<"    "<< setw(10)<<"   "<< setw(10)<<"   "<<endl;
cout<<setfill(' ');
cout<<right;
cout<<setw(2)<<"Bank of Kendal"  <<setw(12)<<"1.08%" << setw(15)<<"4"<<setw(10)<<"$"<<" "<<principal<<setw(5)<<" "<<"$"<<" "<<interest<<setw(3)<<" "<<"$"<<" "<<amount<<endl;

//calculate amount for Bank of Coral Gables.
amount = principal * pow(1.0 +  CG_INTEREST_RATE/ND, ND*T);

//calculate the invesment interest.
interest = amount - principal;



//display results for Bank of Coral Gables.
cout << fixed << showpoint;
cout << setprecision(2);
cout<<right;
cout<<setw(2)<<"Bank of Coral Gables"<<" "<<setw(5)<<"2.10%"<<setw(15)<<"365"<<setw(10)<<"$"<<" "<<principal<<setw(5)<<" "<<"$"<<" "<<interest<<setw(3)<<" "<<"$"<<" "<<amount<<endl;

//calculate amount for Bank of Homestead.
amount = principal * pow(1.0 + HOMESTEAD_INTEREST_RATE/NM, NM*T);

//calculate the invesment interest.
interest = amount - principal;


//display results for Bank of Homestead.
cout << fixed << showpoint;
cout << setprecision(2);
cout<<right;
cout<<setw(2)<<"Bank of Homestead"<<"    "<<setw(5)<<"2.22%"<<setw(15)<<"12"<<setw(10)<<"$"<<" "<<principal<<setw(5)<<" "<<"$"<<" "<<interest<<setw(3)<<" "<<"$"<<" "<<amount<<endl;
//calculate amount for Bank of Homestead.
amount = principal * pow(1.0 + HIALEAH_INTEREST_RATE/NA, NA*T);

//calculate the invesment interest.
interest = amount - principal;

//display results for Bank of Hialeah.
cout << fixed << showpoint;
cout << setprecision(2);
cout<<right;
cout<<setw(2)<<"Bank of Hialeah"<<"      "<<setw(5)<<"4.25%"<<setw(15)<<"1"<<setw(10)<<"$"<<" "<<principal<<setw(5)<<" "<<"$"<<" "<<interest<<setw(2)<<" "<<"$"<<" "<<amount<<endl;




return 0;


}

Output:




No comments:

Post a Comment