Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Compound Interest based on Principle, Rate and Years
- //Libraries and Headers
- #include <iostream>
- #include <cmath>
- using namespace std;
- //Create class
- class calcCompInterest
- {
- public: double principle, radius, time;
- double compoundInterest(){
- return principle * pow(1.0 + radius, time) - principle;
- }
- //create array and give pointers
- calcCompInterest accountInfo[3];
- //input data into array and process via calcCompInterest class
- int main(){
- double accountInfo, interest;
- cout <<"Enter the principal: ";
- cin >> accountInfo[0].principle;
- cout << "\n Enter rate: ";
- cin >> accountInfo[1].rate;
- cout << "\n Enter years: ";
- cin >> accountInfo[2].time;
- cout << "\n The Compound Interest is: " << accountInfo[interest].compoundInterest << endl;
- system ("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement