66 840
Assignments Done
99,1%
Successfully Done
In October 2018

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.
Expert's answer
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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions