Question
C++ Coding Provide copyable code please. Write the process(); functions for BankAccount, MilesDriven, Housesales. So process has everything from bankaccount.cpp (the functions with user input
C++ Coding
Provide copyable code please.
Write the process(); functions for BankAccount, MilesDriven, Housesales. So process has everything from bankaccount.cpp (the functions with user input needed), the menu options in order. Finish the project1main.cpp so everything works correctly. The codes are below, please sove as fast as you can.
//project1main.cpp
#include
using namespace std;
int main() {
}
//BankAccount.cpp
#include
#include "Statistics.h"
#include "BankAccount.cpp"
using namespace std;
int main()
{
BankAccount bank_acc;
char ch;
int user_input;
double amt;
do
{
cout << " \t *** MAIN MENU*** ";
cout << " \t*** 01. DEPOSIT AMOUNT ***";
cout << " \t*** 02. WITHDRAW AMOUNT ***";
cout << " \t*** 03. BALANCE ENQUIRY ***";
cout << " \t*** 04. EXIT *** ";
cout << " ";
cout << " \tEnter the number for desire menu option:";
cin >> user_input;
switch (user_input)
{
case 1: cout << "Enter the amount to deposit:";
cin >> amt;
bank_acc.deposit(amt);
break;
case 2: cout << "How much would to like to withdraw?";
cin >> amt;
bank_acc.withdrawal(amt);
break;
case 3: bank_acc.getBalance();
break;
case 4: //display_bal();
break;
default:
cout << "Invalid entry";
break;
}
} while (user_input != 4);
return 0;
}
//BankAccount.h
#include
#include
#include"statistics.h"
#pragmonce
using namespace std;
class BankAccount{
public:
void deposit(double amount)
{
if (amount <= 100000 && amount >= 0)
{
deposits.add(amount);
}
else
{
cout << "Deposit limit is $0 to $100000" << endl;
}
}
void withdrawal(double amount)
{
if (amount>0)
{
if (getBalance() >= amount)
{
cout << "You don't have sufficient balance." << endl;
}
}
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.mini();
}
double getMinWithdrawal()
{
return withdrawals.mini();
}
double getMaxDeposit()
{
return deposits.maxi();
}
double getMaxWithdrawal()
{
return withdrawals.maxi();
}
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;
}
private:
Statistics deposits;
Statistics withdrawals;
};
//statistics.h
#pragma once #include "bankaccount.h" class Statistics { public: Statistics(); ~Statistics(); Statistics(int capacity); void add(double value); double get(int i); void set(int i, double data); double sum(); double average(); double min(); double max(); double var(); double stdev(); void printStats(); void print(); static void test(); private: int capacity; double* pData; int size; };
//statistics.cpp
#include "bankaccount.h" #include "statistics.h" Statistics::Statistics() { for (int i = 0; i < capacity; i++) { pData[i] = 0; } } Statistics::~Statistics() { } Statistics::Statistics(int capacity) { pData = new double[capacity]; this->capacity = capacity; size = 0; } void Statistics::add(double value) { if (size < capacity) { pData[size] = value; (size)++; } } double Statistics::get(int i) { return pData[i]; } void Statistics::set(int i, double data) { pData[i] = data; } double Statistics::sum() { double sum = 0; for (int i = 0; i < size; i++) { sum += pData[i]; } return sum; } double Statistics::average() { double average; return average = sum()/this->size; } double Statistics::min() { double minimum = pData[0]; for (int i = 1; i < this->size; ++i) if (pData[i] < minimum) { minimum = pData[i]; } return minimum; } double Statistics::max() { double maximum = pData[0]; for (int i = 1; i < size; ++i) if (pData[i] > maximum) { maximum = pData[i]; } return maximum; } double Statistics::var() { double variance; double mean = average(); double num1, num2 = 0; for (int i = 0; i //MilesDriven.cpp #include int main() { MilesDriven tour; tour.addMilesValue(25.25); tour.addMilesValue(55.25); tour.addMilesValue(34); cout<<"Value of 2nd Travel:"< //MilesDriven.h #include //Housesales.h #include //Housesales.cpp #include int main() { Housesales salesPrice; salesPrice.addSalesValue(20000); salesPrice.addSalesValue(25000); salesPrice.addSalesValue(60000); salesPrice.setSalesValue(2,20000); salesPrice.printAllStates(); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started