Foundations Of Computer Science COP 3014 Please provide copyable codes, in C++ P
ID: 3735811 • Letter: F
Question
Foundations Of Computer Science COP 3014
Please provide copyable codes, in C++
Please include the following
bankaccount.cpp
statistics.h
*if needed, provide others
********Here are the functions in UML format so you can copy-n-paste*********
add(value: double): void
get(i: int): double
set(i: int, data: double): void
sum(): double
average(): double
min(): double
max(): double
var(): double
stdev(): double
printStats(): void
******Here are the functions in UML format so you can copy-n-paste:*******
deposit(amount: double): void
withdrawal(amount: double): void
getBalance(): double
getTotalDeposits(): double
getTotalWithdrawals(): double
getAverageDeposit(): double
getAveragWithdrawal(): double
getMinDeposit(): double
getMinWithdrawal(): double
getMaxDeposit(): double
getMaxWithdrawa(): double
getVarOfDeposits(): double
getVarOfWithdrawal(): double
getStdevOfdeposits(): double
getStdevOfWithdrawal(): double
printAllStats(): void
#include "statistics.h"
class BankAccount{
public:
//...
private:
Statistics deposits; //the aggregation relationship
Statistics withdrawals; //the aggregation relationship
};
Bank Account Specifications (Required) This Application stores every transaction as soon as a transaction happens. Only amount of the transaction is stored, the date of transaction or any other data is not stored by this class. When the application starts, it will ask the user about what is the maximum number of expected transactions. You will assume that the balance is zero when the program first starts. The application will allow the user to make deposits as long as the balance is not above $100,000 FDIC limit. The application will allow users to withdraw money as long as the withdrawal amount is no more than the available balance.Explanation / Answer
//code to copy at Statistics.h
#include <iostream>
#include<cmath>
using namespace std;
class Statistics
{
private:
double pdata[];
int index;
int capacity;
int size;
public:
Statistics()
{
index=0;
}
void add(double value)
{
pdata[index]=value;
index++;
}
double get(int i)
{
return pdata[i];
}
void set(int i, double data)
{
pdata[i]=data;
}
double sum()
{
double addition=0;
for(int i=0;i<index;i++)
{
addition+=*(pdata+i);
}
return addition;
}
double average()
{
return sum()/index;
}
double min()
{
double minval=pdata[0];
for(int i=1;i<index;i++)
{
if(minval>pdata[i])
minval=pdata[i];
}
return minval;
}
double max()
{
double maxval=pdata[0];
for(int i=1;i<index;i++)
{
if(maxval<pdata[i])
maxval=pdata[i];
}
return maxval;
}
double var()
{
double add=0,variance=0;
double mean=average();
for(int i=0;i<index;i++)
{
double temp=*(pdata+i)-mean;
add+=(temp*temp);
}
variance=add/(index-1); //var=[sum(x(i)-mean(x)]^2 / n-1
return variance;
}
double stdev()
{
return sqrt(var());
}
void printstats()
{
cout<<"sum="<<sum()<<endl;
cout<<"average="<<average()<<endl;
cout<<"Min Val="<<min()<<endl;
cout<<"Max Val="<<max()<<endl;
cout<<"Variance Val="<<var()<<endl;
cout<<"Standered Deviation Val="<<stdev()<<endl;
}
};
//code to copy to BankAccount class
class BankAccount
{
private:
Statistics deposits;
Statistics withdrawals;
public:
void deposit(double amount)
{
if(amount<=100000&& amount>=0)
{
deposits.add(amount);
}
else
{
cout<<"Deposite limit is $0 to $100000"<<endl;
}
}
void withdrawal(double amount)
{
if(amount>0)
{
if(getBalance()<amount)
{
cout<<getBalance()<<" A."<<amount;
cout<<"You don't have sufficient balance."<<endl;
}
else
{
withdrawals.add(amount);
}
}
else
{
cout<<"Please Enter Positive Value."<<endl;
}
}
double getBalance()
{
return (getTotalDeposits()-getTotalWithdrawals());
}
double getTotalDeposits()
{
return deposits.sum();
}
double getTotalWithdrawals()
{
return withdrawals.sum();
}
double getAverageDeposit()
{
return deposits.average();
}
double getAveragWithdrawal()
{
return withdrawals.average();
}
double getMinDeposit()
{
return deposits.min();
}
double getMinWithdrawal()
{
return withdrawals.min();
}
double getMaxDeposit()
{
return deposits.max();
}
double getMaxWithdrawal()
{
return withdrawals.max();
}
double getVarOfDeposits()
{
return deposits.var();
}
double getVarOfWithdrawal()
{
return withdrawals.var();
}
double getStdevOfdeposits()
{
return deposits.stdev();
}
double getStdevOfWithdrawal()
{
return withdrawals.stdev();
}
void printAllStats()
{
cout<<"balance="<<getBalance()<<endl;
cout<<"getTotalDeposits="<<getTotalDeposits()<<endl;
cout<<"getTotalWithdrawals="<<getTotalWithdrawals()<<endl;
cout<<"getMaxDeposit="<<getMaxDeposit()<<endl;
cout<<"getMaxWithdrawa="<<getMaxWithdrawal()<<endl;
cout<<"getMinDeposit="<<getMinDeposit()<<endl;
cout<<"getMinWithdrawal="<<getMinWithdrawal()<<endl;
cout<<"getVarOfWithdrawal="<<getVarOfWithdrawal()<<endl;
cout<<"getVarOfDeposits="<<getVarOfDeposits()<<endl;
cout<<"getStdevOfdeposits="<<getStdevOfdeposits()<<endl;
cout<<"getStdevOfWithdrawal="<<getStdevOfWithdrawal()<<endl;
}
};
// Your .cpp code
int main()
{
BankAccount account;
account.deposit(25000);
account.withdrawal(30000);
account.withdrawal(5000);
account.deposit(2000);
account.deposit(50000);
account.withdrawal(12000);
cout<<"Your Account Balance is:"<<account.getBalance();
account.printAllStats();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.