Create a new project and create a class called Account to provide services of a
ID: 3620239 • Letter: C
Question
Create a new project and create a class called Account to provide services of a bank. When you define the class, you have to provide data member to store account holder’s name, account number, and current balance.(1) Define a function member called set (string name, int number, double balance) to set the values of an object.
(2) Define a function member called deposit (double amount) to deposit some fund to the account.
If the deposit succeeded, this function should return true. However, if the deposit failed by any reason, for example, a negative amount deposit, it should return false.
(3) Define a function member called withdrawal (double amount) to withdraw some fund from the account. If the current balance is not enough for the withdrawal, this function should return false. Otherwise, it should return true.
(4) Define a member function called inquiry() to display the account holder’s name, account number, and current balance on the screen. Based on the information given above, write an interface file called Account.h and an implementation
file called Account.cpp. Test your class with a driver program given below. If you found any problem at the driver program, fix it.
//--- Test driver for class Account
#include <iostream>
using namespace std;
#include "Account.h"
int main()
{
Account boa;
Account citi;
boa.set(“John”, 1234, 10.0);
cout << “boa.withdrawal(5.00) ” << boa.withdrawal(5.00) << endl;
cout << “boa.withdrawal(7.00) ” << boa.withdrawal(7.00) << endl;
boa.deposit(5.00);
boa.inquiry();
citi.set(“Tom”, 2277, 100.0);
citi.deposit(-100.0);
citi.inquiry();
return 0;
}
Explanation / Answer
First off, this program will take three files, as you said. There will be the driver file (main.cpp), the header file / interface file (Account.h), and implementation file (Account.cpp).Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.