1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
//Start
#include<iostream>
#include<cmath>
using namespace std;
//Constructor
class CompoundInt
{
private:
double princ, rate, frequency, time, fv, compoundPeriod;
public:
//constructor
CompoundInt(double p, double r, double f, double t, double n)
{
princ = p;
rate = r;
frequency = f;
time = t;
compoundPeriod = n;
}
//getters
double getPrinc() {
cout << "Enter the principal amount:";
cin >> princ;
return princ;
}
double getRate() {
cout << "Enter the rate:";
cin >> rate;
return rate;
}
double getFrequency() {
cout << "Enter the frequency:";
cin >> frequency;
return frequency;
}
double getTime() {
cout << "Enter the time:";
cin >> time;
return time;
}
double getCompoundPeriod() {
cout << "Enter the compound period:";
cin >> compoundPeriod;
return compoundPeriod;
}
//setters
void setPrinc(double p) { princ = p; }
void setRate(double r) { rate = r; }
void setFrequency(double f) { frequency = f; }
void setTime(double t) { time = t; }
void setCompoundPeriod(double n) { compoundPeriod = n; }
//calculation
double calcFV() {
double fv = princ * pow((1 + (rate / compoundPeriod)), (time * compoundPeriod));
return fv;
}
};
int main()
{
CompoundInt ci(double princ, double rate, double frequency, double time, double fv, double compoundPeriod);
cout << "Principle at "
<< ci.getPrinc()
<< ci.calcFV() << endl;
system("pause");
return 0;
}
//End Code
|