0% found this document useful (0 votes)
22 views3 pages

Summer Project

The document is a C++ program that simulates a banking system with classes for Bank, Account, money, and Manager. It allows users to perform actions such as crediting and debiting amounts, checking balance, and verifying passwords. The main function creates a Manager object and executes banking operations while displaying account details.

Uploaded by

shivansh1909sri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

Summer Project

The document is a C++ program that simulates a banking system with classes for Bank, Account, money, and Manager. It allows users to perform actions such as crediting and debiting amounts, checking balance, and verifying passwords. The main function creates a Manager object and executes banking operations while displaying account details.

Uploaded by

shivansh1909sri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <iostream>

#include <string>
using namespace std;

class Bank {
protected:
double balance;

public:
Bank() : balance(10000.20) {}

void credit(double amount) {


if (amount > 0) {
balance += amount;
cout << "Amount credited successfully: $" << amount << endl;
} else {
cout << "Invalid credit amount." << endl;
}
}

void debit(double amount) {


if (amount > 0 && amount <= balance) {
balance -= amount;
cout << "Amount debited successfully: $" << amount << endl;
} else {
cout << "Insufficient balance or invalid debit amount." << endl;
}
}

double getBalance() {
return balance;
}
};

class Account : public Bank {


protected:
string accountNumber;
string accountHolder;
int pass;

public:
Account(const string& number, const string& holder, int password) :
accountNumber(number), accountHolder(holder), pass(password) {}

void display() {
cout << "Account Number: " << accountNumber << endl;
cout << "Account Holder: " << accountHolder << endl;
cout << "Balance: $" << getBalance() << endl;
}

bool verifyPassword() {
int enteredPass;
cout << "Enter your password: ";
cin >> enteredPass;
return (enteredPass == pass);
}
};

class money : public Account {


public:
money(const string& number, const string& holder, int password) :
Account(number, holder, password) {}

void performMoneyactions() {
if (!verifyPassword()) {
cout << "Invalid password." << endl;
return;
}

int choice;
cout << "money Actions Menu:\n";
cout << "1. Credit\n2. Debit\n3. Check Balance\n";
cin >> choice;
switch (choice) {
case 1:
double creditAmount;
cout << "Enter the amount to credit: $";
cin >> creditAmount;
credit(creditAmount);
break;
case 2:
double debitAmount;
cout << "Enter the amount to debit: $";
cin >> debitAmount;
debit(debitAmount);
break;
case 3:
display();
break;
default:
cout << "Invalid choice." << endl;
}
}
};

class Manager : public money {


public:
Manager(const string& number, const string& holder, int password) :
money(number, holder, password) {}

void performManagerActions() {
if (!verifyPassword()) {
cout << "Invalid password." << endl;
return;
}

money::performMoneyactions();
display(); // Display account number and account holder name
cout << "Updated Balance: $" << getBalance() << endl;
}
};

int main() {
cout<<endl;
cout<<"======================================================="<<endl;
cout<<"***********WELCOME TO GOPIYA BANK OF NAINI************ "<<endl;
cout<<"======================================================="<<endl;
cout<<endl;
string accountNumber = "LMAO2345";
string accountHolder = "SHIVANSH SRIVASTAVA THE GREAT";
int password = 2003;

Manager manager(accountNumber, accountHolder, password);


manager.performManagerActions();

return 0;
}

You might also like