Question

In: Computer Science

I am just trying to make confNum static so all my classes can use. Can me...

I am just trying to make confNum static so all my classes can use. Can me help with that please.

.h

#include <stdio.h>

#include <iomanip>

#include <stdlib.h>

#include <time.h>

#include "Customer.hpp"

#include "Employee.hpp"

class BankAccount: public Customer

{

protected:

long AccountNumber;

double Balance;

int confNum;

public:

  

BankAccount(const string&, const string&, const string&, const string&,long , double, int);//constructor

  

void setAccountNumber(long);

long getAccountNumber()const;

  

void setBalance(double);

double getBalance()const;

  

void setConfNum(int);

int getConfNum();

  

virtual void deposit(double);

virtual void withdrawl(double);

virtual void writeCheck(double);

virtual void print();

  

  

};

#endif /* Bank_Account_hpp */

.cpp

#include "Bank Account.hpp"

#include "Teller.hpp"

double Teller::registerCash;//Static member

BankAccount::BankAccount(const string& first, const string& last, const string& social,const string& IDN,long AccNum, double balance,int num): Customer(first,last,social,AccNum,IDN)

{

setAccountNumber(AccNum);

setBalance(balance);

setConfNum(num);

}

void BankAccount::setAccountNumber(long AccNum)

{

if(AccNum>1000000000 && AccNum<9999999999)

{

AccountNumber=AccNum;

}

}

long BankAccount::getAccountNumber()const

{

return AccountNumber;

}

void BankAccount::setBalance(double balance)

{

if(balance>0)

{

Balance = balance;

}

}

double BankAccount:: getBalance() const

{

return Balance;

}

void BankAccount:: setConfNum(int num)

{

num=(num+1);

confNum=num;

}

int BankAccount::getConfNum()

{

return confNum;

  

}

void BankAccount::deposit(double amount)

{

Teller::registerCash=amount+Teller::registerCash;

Balance=Balance+amount;

cout<<"The amount of $"<<amount<<" was deposited to the Account #"<<getAccountNumber()<<"."<<endl;

   cout<<"The confirmation number: "<< getConfNum()<<"."<<endl<<endl;

}

void BankAccount:: withdrawl(double amount)

{

   if(Balance>= amount)

{

Teller::registerCash=Teller::registerCash-amount;

Balance=Balance-amount;

cout<<"The amount of $"<<amount<<" was withdrawn from the Account # "<<getAccountNumber()<<"."<<endl;

cout<<"The confirmation number: "<< getConfNum()<<"."<<endl<<endl;

}

else

{

cout<<"There is not enough money to withdrawl";

}

  

}

void BankAccount::writeCheck(double amount)

{

if(amount<=Balance)

{

cout<<endl<< "A check was written from the account and the ammount of the check is $"<<amount<<"."<<endl;

withdrawl(amount);

}

else

{

cout<<"There is not enough money available for writing this check"<<endl;

}

}

void BankAccount:: print()

{

cout<<"Bank Account#: "<<getAccountNumber()<<" Balance: $"<< setprecision(2) << fixed << getBalance()<<"."<<endl<<endl;

}

Solutions

Expert Solution

Please find the modified code below.

CODE

#include <stdio.h>

#include <iomanip>

#include <stdlib.h>

#include <time.h>

#include "Customer.hpp"

#include "Employee.hpp"

class BankAccount: public Customer

{

protected:

long AccountNumber;

double Balance;

static int confNum;

public:

BankAccount(const string&, const string&, const string&, const string&,long , double, int);//constructor


void setAccountNumber(long);

long getAccountNumber()const;


void setBalance(double);

double getBalance()const;


void setConfNum(int);

int getConfNum();


virtual void deposit(double);

virtual void withdrawl(double);

virtual void writeCheck(double);

virtual void print();



};

#endif /* Bank_Account_hpp */

.cpp

#include "Bank Account.hpp"

#include "Teller.hpp"

double Teller::registerCash;//Static member

int BankAccount::confNum = 0;

BankAccount::BankAccount(const string& first, const string& last, const string& social,const string& IDN,long AccNum, double balance,int num): Customer(first,last,social,AccNum,IDN)

{

setAccountNumber(AccNum);

setBalance(balance);

setConfNum(num);

}

void BankAccount::setAccountNumber(long AccNum)

{

if(AccNum>1000000000 && AccNum<9999999999)

{

AccountNumber=AccNum;

}

}

long BankAccount::getAccountNumber()const

{

return AccountNumber;

}

void BankAccount::setBalance(double balance)

{

if(balance>0)

{

Balance = balance;

}

}

double BankAccount:: getBalance() const

{

return Balance;

}

void BankAccount:: setConfNum(int num)

{

num=(num+1);

confNum=num;

}

int BankAccount::getConfNum()

{

return confNum;


}

void BankAccount::deposit(double amount)

{

Teller::registerCash=amount+Teller::registerCash;

Balance=Balance+amount;

cout<<"The amount of $"<<amount<<" was deposited to the Account #"<<getAccountNumber()<<"."<<endl;

cout<<"The confirmation number: "<< getConfNum()<<"."<<endl<<endl;

}

void BankAccount:: withdrawl(double amount)

{

if(Balance>= amount)

{

Teller::registerCash=Teller::registerCash-amount;

Balance=Balance-amount;

cout<<"The amount of $"<<amount<<" was withdrawn from the Account # "<<getAccountNumber()<<"."<<endl;

cout<<"The confirmation number: "<< getConfNum()<<"."<<endl<<endl;

}

else

{

cout<<"There is not enough money to withdrawl";

}


}

void BankAccount::writeCheck(double amount)

{

if(amount<=Balance)

{

cout<<endl<< "A check was written from the account and the ammount of the check is $"<<amount<<"."<<endl;

withdrawl(amount);

}

else

{

cout<<"There is not enough money available for writing this check"<<endl;

}

}

void BankAccount:: print()

{

cout<<"Bank Account#: "<<getAccountNumber()<<" Balance: $"<< setprecision(2) << fixed << getBalance()<<"."<<endl<<endl;

}


Related Solutions

Hello Everyone, Can anyone tell me why my program will not run? I am trying to...
Hello Everyone, Can anyone tell me why my program will not run? I am trying to work on abstract base classes... not sure what is going on. import math from abc import ABC from abc import abstractmethod #TODO: convert this to an ABC class Shape(ABC): def __init__(self): self.name = "" def display(self): print("{} - {:.2f}".format(self.name, self.get_area())) #TODO: Add an abstractmethod here called get_area @abstractmethod def get_area(self): if self.name == "Circle": get_area()= 3.14 * radius * radius else: get_area() = self.length...
I am trying to start saving for retirement. I am investing all my cash into the...
I am trying to start saving for retirement. I am investing all my cash into the S&P 500, which will assume consistently 9.8% interest, compounded annually. I initially put a lump sum of $100 into my account, and I will deposit $10 every second week. a) After 10 years, how much money will I have invested? b) After 10 years, if I sold all of my stocks, how much money will I have in my account? c) After 25 years,...
I am trying to make a new code that uses functions to make it. My functions...
I am trying to make a new code that uses functions to make it. My functions are below the code. <?php */ $input; $TenBills = 1000; $FiveBills = 500; $OneBills = 100; $Quarters = 25; $Dimes = 10; $Nickels = 5; $Pennies = 1; $YourChange = 0; $input = readline("Hello, please enter your amount of cents:\n"); if(ctype_digit($input)) { $dollars =(int)($input/100); $cents = $input%100;    $input >= $TenBills; $YourChange = (int)($input/$TenBills); $input -= $TenBills * $YourChange; print "Change for $dollars dollars...
NOTE: I am just checking my own work so if you respond, please make sure I...
NOTE: I am just checking my own work so if you respond, please make sure I can read your handwriting. A loan officer wants to compare the interest rates for 48-month fixed-rate auto loans and 48-month variable-rate auto loans. Two independent, random samples of auto loans are selected. A sample of eight 48-month fixed-rate auto-loans have the following loan rates: 4.29%, 3.75%, 3.50%, 3.99%, 3.75%, 3.99%, 5.40%, 4.00% while a sample of five 48-month variable-rate auto loans have the loan...
Working with Python. I am trying to make my code go through each subject in my...
Working with Python. I am trying to make my code go through each subject in my sample size and request something about it. For example, I have my code request from the user to input a sample size N. If I said sample size was 5 for example, I want the code to ask the user the following: "Enter age of subject 1" "Enter age of subject 2" "Enter age of subject 3" "Enter age of subject 4" "Enter age...
I am having an issue with trying to make my code to have a required output...
I am having an issue with trying to make my code to have a required output ////////////Input////////// With computer science, you can work in any industry. 0 //////////Output////////// Required Output Enter some text to encrypt\n Enter a key\n Error: Key is divisible by 26. That's a bad key!\n Useless key: 0\n ///////////Cipher.java///////// ------------ My code. public class Cipher { private String plainText; private int key; public Cipher(String text, int key) throws EmptyPlainText, UselessKeyException { if (text == null || text.length()...
This is an Android Question. I am trying to make a FAB(Floating Action Button) show me...
This is an Android Question. I am trying to make a FAB(Floating Action Button) show me a different page when I press it.
I JUST WANT AN EXAMPLE ANSWER SO I CAN MAKE MY OWN. THANK YOU!! Conduct research...
I JUST WANT AN EXAMPLE ANSWER SO I CAN MAKE MY OWN. THANK YOU!! Conduct research on New York City's large soda ban. Pretend you work at the Paradise City attorney's office. Draft a law that restricts the sale of large sugary drinks in Paradise City. Make sure to define the types of drinks and types of sellers restricted by the law. Example Statute: Title XXXIV (Links to an external site.)Links to an external site. ALCOHOLIC BEVERAGES AND TOBACCO Chapter...
I am trying to figure out which test analysis to use for my research questions. I...
I am trying to figure out which test analysis to use for my research questions. I was thinking about think about multivariate because of the number of variable being addressed in the study but there is also the possibility to use univariate to address each question. What are the current levels of police satisfaction in CMPD jurisdictions? What is the public’s perception of crime in CMPD jurisdictions? Does “hot spot” policing reduce crime in CMPD jurisdictions? How does broken windows...
In trying to apply my knowledge in the real world, I am trying to create a...
In trying to apply my knowledge in the real world, I am trying to create a realistic retirement schedule. However, I am running into difficulties using both a financial calculator as well as our equations from class in doing this. I am trying to do the following: plan a retirement schedule between the ages of 25 and 70, in which I would deposit 20% of my income each year. The income starts at 80,000 with an annual growth rate of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT