Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Rothschild Bank//
- #include <iostream>
- #include <string>
- #include <stdlib.h>
- using namespace std;
- class Account {
- private:
- double account_balance; char account_type; int account_number;
- public:
- Account() {
- account_balance = 0.00;
- account_type = 's';
- account_number = 0;
- }
- double make_depo(double money) {
- account_balance += money;
- return account_balance;
- }
- double make_withdrawl(double money) {
- if (account_type == 'c')
- account_balance -= money;
- else {
- if (money >= 10000) {
- cout << "Your account is a Standard Account, you can't take more that $10000\n";
- cout << "Making Your Witdrawl Limit to $10000\n";
- money = 10000;
- }
- account_balance -= money;
- }
- return account_balance;
- }
- double get_account_balance() {
- return account_balance;
- }
- string get_account_type() {
- if (account_type == 'c') return "Commercial Account";
- return "Standard Account";
- }
- int get_account_number() {
- return account_number;
- }
- double setCustomerAccount(double depo_money,char acc_type,int ac_number) {
- account_balance = depo_money;
- account_type = acc_type;
- account_number = ac_number;
- return account_balance;
- }
- };
- class Customer {
- private:
- Account customer_account; string account_holder;
- public:
- void make_bank_account(int* reserveAccount,int* sizeofArr) {
- char temp; int ac_num,takenFlag=0, flag = 0;
- cout << "Enter Account Holder's Name: "; cin >> account_holder;
- cout << "[c]Commercial Account or [s]Standard Account: "; cin >> temp;
- while(flag == 0){
- cout << "Enter Your Custom Account Number: "; cin >> ac_num;
- takenFlag=0;
- for (int i = 0;i < *sizeofArr;i++){
- if (reserveAccount[i] == ac_num){
- cout << "Account Already Taken\n\n";
- takenFlag = 1;
- break;
- }
- }
- if(takenFlag == 1){
- flag = 0;
- } else{
- flag = 1;
- }
- }
- cout << customer_account.setCustomerAccount(100.00, temp, ac_num) << "$ Your Current Account Balance" << endl << endl;
- reserveAccount[(*sizeofArr)++] = ac_num;
- }
- void show_account_details() {
- cout << "\t\tA.C.C.O.U.N.T H.O.L.D.E.R.S D.E.T.A.I.L.S " << endl << endl;
- cout << "Account Holder Name: " << account_holder << endl;
- cout << "Account Balance: " << customer_account.get_account_balance() << endl;
- cout << "Account Type is: " << customer_account.get_account_type() << endl;
- cout << "Account Number Assigned: " << customer_account.get_account_number() << endl;
- }
- void depositMoney() {
- cout << "\t\tD.E.P.O.S.I.T MONEY" << endl << endl;
- double money;
- cout << "Enter The Amount: "; cin >> money;
- cout << "ACCOUNT BALANCE: " << customer_account.make_depo(money) << endl;
- }
- void withdrawlMoney() {
- cout << "\t\tW.I.T.H.D.R.A.W.L MONEY" << endl << endl;
- double money;
- cout << "Enter The Amount: "; cin >> money;
- cout << customer_account.make_withdrawl(money) <<endl;
- }
- int get_Account_number() {
- return customer_account.get_account_number();
- }
- void send_money(double money) {
- customer_account.make_withdrawl(money);
- }
- void recieve_money(double money) {
- customer_account.make_depo(money);
- }
- };
- class ROTHSCHILDBANKINGSYSTEM {
- Customer cus[20]; int totalCustomer = 0;int sizeofArr=0;
- int* reserveAccount = (int*)calloc(10,sizeof(int));
- public:
- void reserveArr(){
- for (int i =0 ;i<sizeofArr;i++){
- cout << reserveAccount[i] << " ";
- }
- cout << endl;
- }
- void set_customer(int num_of_new_customer) {
- for (num_of_new_customer += totalCustomer; totalCustomer < num_of_new_customer;totalCustomer++) {
- reserveArr();
- cus[totalCustomer].make_bank_account(reserveAccount,&sizeofArr);
- cus[totalCustomer].depositMoney();
- cus[totalCustomer].show_account_details();
- reserveArr();
- system("pause");
- system("cls");
- }
- }
- void transferMoney(int fromAccount, int toAccount, double money) {
- Customer to_cus, from_cus; int from_pos = -1, to_pos = -1;
- for (int i = 0; i < 20; i++) {
- if (from_pos != -1 && to_pos != -1) break;
- if (cus[i].get_Account_number() == fromAccount) {
- from_cus = cus[i]; from_pos = i;
- }
- if (cus[i].get_Account_number() == toAccount) {
- to_cus = cus[i]; to_pos = i;
- }
- }
- if (from_pos == -1 || to_pos == -1) {
- cout << "ERROR: Maybe one or both the Account Number is Wrong!!!\n\n";
- return;
- }
- from_cus.send_money(money); // from A money is Deducting
- to_cus.recieve_money(money); // to B Money is Incrementing
- cus[from_pos] = from_cus;
- cus[to_pos] = to_cus;
- //==============Showing Remaining Balance==============//
- cout << "\nSENDER\n";
- cus[from_pos].show_account_details();
- cout << "\nRECIVER\n";
- cus[to_pos].show_account_details();
- }
- void show_customer_details(int account_number) {
- for (auto i : cus) {
- if (i.get_Account_number() == account_number) {
- i.show_account_details();
- return;
- }
- }
- cout << "No Such Customer Exists\n\n";
- }
- };
- //=====================Main==========================//
- #include "banking.h"
- #include <fstream>
- void add_new_bank_customers();
- void getCustomerDetails();
- void transfer_money();
- void update_database();
- void view() {
- system("pause");
- system("cls");
- }
- ROTHSCHILDBANKINGSYSTEM rchild;
- int main() {
- int choice; int flag = 0;
- while (true) {
- cout << "1. Add Customer\n2.Get Customer Details\n3.Transfer Money\n4.Update Database\n:~# ";
- cin >> choice;
- switch (choice)
- {
- case 1:
- add_new_bank_customers(); break;
- case 2:
- getCustomerDetails(); view(); break;
- case 3:
- transfer_money(); view(); break;
- case 4:
- update_database(); break;
- default:
- flag = 1;
- break;
- }
- if (flag == 1) { break; }
- }
- return 0;
- }
- void transfer_money() {
- int send_ac_num, rec_ac_num; double money;
- cout << "Enter Senders Account Number: "; cin >> send_ac_num;
- cout << "Enter Receivers Account Number: "; cin >> rec_ac_num;
- cout << "Enter Your Amount Money: "; cin >> money;
- rchild.transferMoney(send_ac_num,rec_ac_num,money);
- }
- void add_new_bank_customers() {
- int total;
- cout << "How Many Customer Account Are to be open ?: "; cin >> total;
- rchild.set_customer(total);
- }
- void getCustomerDetails() {
- int account_num;
- cout << "Enter The Account Number: "; cin >> account_num;
- rchild.show_customer_details(account_num);
- }
- void update_database() {
- ofstream rchild_db;
- rchild_db.open("bankDatabase.bin",ios::out|ios::binary);
- if (rchild_db.is_open()) {
- cout << "updating relational database...\n";
- rchild_db.write((char*)(&rchild), sizeof(ROTHSCHILDBANKINGSYSTEM));
- }
- else {
- cout << "fail to open database...\n"; return;
- }
- rchild_db.close();
- }
Add Comment
Please, Sign In to add comment