Question

Simple Banking System

Imagine you are tasked with implementing a basic banking

system. For simplicity, a bank account will have the following features:

• An account number (randomly generated)

• An account holder's name

• A balance

**Objective: Design a class named BankAccount that implements the above features

and provides the following functionalities:

1. Deposit an amount.

2. Withdraw an amount (Ensure that the balance doesn’t go negative).

3. Print the account details.

**Instructions:

1. Define a class BankAccount.

2. Use appropriate private attributes for account number, account holder's

name, and balance.

3. Provide methods for depositing, withdrawing, and printing account

details.

4. In the main() function, demonstrate the use of the BankAccount class by

creating an object, depositing, withdrawing, and printing its details.

**Hints:

• Consider using the rand() function to generate a random account number.

• Ensure that the withdraw method checks if there's enough balance before

proceeding.

*/

#include

#include

#include

using namespace std;/npublic:

// Constructor

BankAccount (string name) {

srand(time(0));

// TODO: Initialize the account number using the rand() function

account Number = // Fill this in

// TODO: Initialize the accountHolder with the given name

accountHolder = // Fill this in

balance =

}

// Method to deposit an amount

void deposit (double amount) {

// TODO: Add the deposited amount to the balance and print the new balance

cout << "Depositing $" << amount << endl;

cout << "New Balance: $" << balance << endl;

}

// Method to withdraw an amount

void withdraw(double amount) {

if (amount > balance) {

}

cout << "Insufficient funds. Withdrawal declined." << endl;

} else {

// TODO: Deduct the amount from the balance

https://mediatb.blob.core.windows.net/media/orders/64f2a4578874b825636bfa87/Lab7-1697248956424.cpp

10/14/23, 7:49 AM

}

0.0; // Starting balance is always

mediatb.blob.core.windows.net/media/orders/64f2a4578874b825636bfa87/Lab7-1697248956424.cpp

cout << "Withdrawing $" << amount << endl;

cout << "New Balance: $" << balance << endl;

// Method to print account details

void printAccountDetails() {

cout << "-- Account Details --" << endl;

cout << "Account Number: << account Number << endl;

cout << "Account Holder: << accountHolder << endl;

cout << "Balance: $" << balance << endl;

"1

Question image 1Question image 2