Answer to Question #31784 in C++ for Jay

Question #31784
Implement a class account. An account has a balance, functions to add and withdraw money, and a function to query the current balance. Charge a $5 penalty if an attempt is made to withdraw more money than available in the account.
1
Expert's answer
2013-06-11T08:37:45-0400
class Account
{
private:
double balance;

public:
Account()
{
balance = 0.0;
}

double GetBalance()
{
return balance;
}

void AddMoney(double amount)
{
balance += amount;
}

void WithdrawMoney(double amount)
{
if (amount > balance && balance >= 5.0)
balance -= 5.0;
else
balance -= amount;
}
};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS