CPP Assignment

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

Bank.

h
====
#include <iostream>
#include <string>
#include <array>
using namespace std;
//***************************************************************
//
CLASS USED IN PROJECT
//****************************************************************
class BankAccount
{
public:
static const size_t arrBalSize = 15;
void setOwnerAge(int); //function to set the age of account owner
int getOwnerAge();//function to return the age
void setOwnerName(string);//function to set the account owner name
string getOwnerName(); //function to return ownername
void seBalances(int); //function to set the balances
double totalMonthlyBal();//function to return total monthly balances for
15 months period
double getBalancesAvg();//function to return the Average Value
double calculateInterest();//function to return the interest
double totalBalance();//function to compute total bal
void process_balances();//function to call the functions
private:
int ownerAge;
string ownerName;
double numBalances;
array<float,arrBalSize > arrayBalances;
}; //class ends here
Bank.cpp
=======
#include "Bank.h"
#include<iostream>
#include <array>
#include<string>
using namespace std;
int age;
int bal;
string acctName;
array<float, 12> balances;
void Bank::setOwnerAge(int ownerAge) {
age = ownerAge;
}
int Bank::getOwnerAge() {
return age;
}
void Bank::setOwnerName(string ownerName) {
acctName = ownerName;
}
string Bank::getOwnerName() {
return acctName;

}
void Bank::seBalances(int bal) {
double intbal = 0;
for (int i = 1; i <arrBalSize; i++) {
balances[i] = balances[i]+100;
}
}
double Bank::getTotalBal() {
double sumBalances = 0;
for (int i =0; i<arrBalSize; i++) {
sumBalances += balances[i];
}
return sumBalances;
}
double Bank::getAvg() {
float sumBalances = 0;
for (int i = 0; i < arrBalSize; i++) {
sumBalances += balances[i];
}
double avg = sumBalances / arrBalSize;
return avg;
}
double Bank::calculateInterest() {
double interest = 0;
for (int i = 0; i <arrBalSize; i++) {
interest += balances[i] * 0.02;
}
return interest;
}
double Bank::totalBalance() {
double averages = getTotalbal();
double interest = calculateInterest();
double totBalance = averages + interest;
return totBalance;
}
void Bank::process_balances() {
cout << "Account OwnerName::" << getOwnerName() << endl;
cout << "Account OwnerAge:::" << getOwnerAge() << endl;
cout << "Balance for the 12 periods is ::" << getTotalbal() << endl;
cout << "Average Balances::" << getAvg() << endl;
cout << "Interest for the 15 months period is::" << calculateInterest()
<< endl;;
cout << "Total Balance for the Complete Duration is::" << totalBalance()
<< endl;
}
BankApp.cpp
=============
#include "Bank.h"
#include<iostream>
#include<string>
using namespace std;
int main() {
Bank bankApp;
cout << "please enter age" << endl;
int age;
string name;
int bal;

cin >> age;


bankApp.setOwnerAge(age);
cout << "please enter name" << endl;
cin >> name;
bankApp.setOwnerName(name);
cout << "please enter balance" << endl;
cin >> bal;
bankApp.seBalances(bal);
bankApp.process_balances();
system("pause");
};

You might also like