Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help in C++ I currently have all of this and need what is in the picture to be helped with Account.h #ifndef ACCOUNT_H #define ACCOUNT_H

Help in C++

I currently have all of this and need what is in the picture to be helped with

Account.h

#ifndef ACCOUNT_H #define ACCOUNT_H #include

using namespace std;

class Account { private: int accountNumber; double balance; string ownerName; static double totalNetDeposits; static int numberAccounts;

public: Account(); //Default Constructor Account(int number, string name, double bal); bool withdraw(double amount); bool deposit(double amount); int getAccountNumber(); //Accessors string getName(); double getBalance(); void setAccount(int number, string name, double bal); //Mutators void setAccountNumber(int Account); void setName(string name); void setBalance(double amount); static void setTotalNetDeposits(double amount); static double getTotalNetDeposits(); static int getNumberAccounts(); static void setNumberAccounts(int num); }; #endif

Account.cpp

#include "Account.h" #include

using namespace std;

double Account::totalNetDeposits; int Account::numberAccounts;

Account::Account() { accountNumber = 9999; ownerName = " "; balance = 0.0; } Account::Account(int number, string name, double bal) { setAccount(number, name, bal); } void Account::setAccount(int number, string name, double bal) { accountNumber = number; ownerName = name; balance = bal; setTotalNetDeposits(getTotalNetDeposits() + bal); setNumberAccounts(getNumberAccounts() + 1); } double Account::getBalance() { return balance; } bool Account::withdraw(double amnt) // Checks the withdraw balance { if (amnt > getBalance()) { return false; } else { setBalance(getBalance() - amnt); return true; } } bool Account::deposit(double amnt) //Checks the deposit balance { if (amnt

void Account::setAccountNumber(int number) //Mutators { accountNumber = number; } void Account::setName(string name) { ownerName = name; } void Account::setBalance(double bal) { balance = bal; setTotalNetDeposits(getTotalNetDeposits() + bal); }

void Account::setTotalNetDeposits(double amount) { totalNetDeposits = amount; } double Account::getTotalNetDeposits() { return totalNetDeposits; } int Account::getNumberAccounts() { return numberAccounts; } void Account::setNumberAccounts(int num) { numberAccounts = num; }

Date.h

#ifndef DATE_H #define DATE_H

#include

using namespace std; class Date { private: int month; int day; int year; public:

void setMonth(int month_) { month = month_; } int getMonth() { return month; } void setDay(int day_) { day = day_; } int getDay() { return day; } void setYear(int year_) { year = year_; } int getYear() { return year; } void set(int m, int d, int y) { month = m; day = d; year = y; } Date operator++() { month++; day++; year++; return *this; } bool operator d.year) { return false; } else if (month d.month) { return false; } else if (day d.day) { return false; } } bool operator == (const Date & d) { if (month == d.month && day == d.day && year == d.year) return true; else return false; } bool operator

};

#endif

Main.cpp

#include #include "Account.h" #include "Date.h" #include #include using namespace std; #include

int getMonth(string d) { return atoi(d.substr(0, 2).c_str()); } int getDay(string d) { return atoi(d.substr(3, 2).c_str()); } int getYear(string d) { return atoi(d.substr(6, 4).c_str()); } int main() { int accountNumber; string name; double balance, amount; bool flag = false; bool found = false; int NUM_ACCOUNT = 5, i = 0; Account *accounts; accounts = new Account[NUM_ACCOUNT]; int total = 0; int month, year, day;

const int NUM_DATES = 4; string dateArray[NUM_DATES] = { "02/12/2017", "02/12/2018", "02/13/2017", "03/12/2017" };

cout

Date d1, d2; for (int i = 0; i

cout > choice; cout > accountNumber; for (int x = 0; x > balance; accounts[i].setBalance(balance); cout > accountNumber; cout > amount; cout > accountNumber; cout > amount; for (int x = 0; x

return 0; }

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

image text in transcribed

The output should look similiar to this

image text in transcribedimage text in transcribed

Your program should implement the following 1. Account class Account has the following member variables private accountNumber of type int ownerName of type string number Accounts of type static int, initialized to zero protected: balance of type double totalNet Deposits of type static double totalNetDeposits is the cumulative sum of all deposits (at account creation and at deposits) minus the cumulative sum of all withdrawals and the following member functions: public Account (number, name, amount is the constructor that initializes the account's member variables with number, name and amount. amount is the amount deposited when the account is created. The amoun is added to totalNetDeposits. numberAccounts is incremented withdraw amount function to withdraw a specified amount from the account. The function should first check if there is sufficient balance in the account. If the balance is sufficient, withdrawal is processed. Otherwise the withdrawal is not made. If the withdrawal is made, the withdrawal amount is deducted from balance and from totalNetDeposits. deposit (amount) function to deposit a specified amount of money to the account. The function should first check ifthe deposit amount is positive. If it is positive, deposit is processed. Otherwise the deposit is not made. If the deposit is made, the amount is added to balance and to totalNetDeposits. getAccountNumber An accessor function that returns the account number getBalance An accessor function that returns the account balance

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

How many three-digit numbers are divisible by 7?

Answered: 1 week ago

Question

What is Indian Polity and Governance ?

Answered: 1 week ago