0% found this document useful (0 votes)
33 views4 pages

Opps2 PDF

Uploaded by

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

Opps2 PDF

Uploaded by

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

2.

#include <iostream.h>

#include <string.h>

using namespace std;

class BankAccount

private:

string depositorName;

long accountNumber;

char accountType;

double balance;

public:

void initialize(string name, long accNumber, char type, double initialBalance)

depositorName = name;

accountNumber = accNumber;

accountType = type;

balance = initialBalance;

void deposit(double amount)

balance += amount;

void withdraw(double amount)

{
if (amount <= balance)

balance -= amount;

cout << "Withdrawal of Rs. " << amount << " successful." << endl;

else

cout << "Insufficient balance. Withdrawal failed." << endl;

void display()

cout << "Depositor Name: " << depositorName << endl;

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

cout << "Account Type: " << accountType << endl;

cout << "Balance: Rs. " << balance << endl;

};

int main()

BankAccount accounts[5];

for (int i = 0; i < 5; i++)

string name;

long accNumber;

char type;

double initialBalance;
cout << "Enter depositor name for account " << i+1 << ": ";

cin >> name;

cout << "Enter account number: ";

cin >> accNumber;

cout << "Enter account type (S for Savings, C for Current): ";

cin >> type;

cout << "Enter initial balance: Rs. ";

cin >> initialBalance;

accounts[i].initialize(name, accNumber, type, initialBalance);

for (int i = 0; i < 5; i++)

cout << "\nAccount Details for Customer " << i+1 << ":" << endl;

accounts[i].display();

double depositAmount, withdrawAmount;

cout << "Enter amount to deposit: Rs. ";

cin >> depositAmount;

accounts[i].deposit(depositAmount);

cout << "Enter amount to withdraw: Rs. ";

cin >> withdrawAmount;

accounts[i].withdraw(withdrawAmount);

cout << "Updated Account Details for Customer " << i+1 << ":" << endl;

accounts[i].display();

return 0;

}
Output :-

Enter depositor name for account 1: naresh

Enter account number: 234

Enter account type (S for Savings, C for Current): s

Enter initial balance: Rs. 5600

Enter depositor name for account 2: jay

Enter account number: 345

Enter account type (S for Savings, C for Current): c

Enter initial balance: Rs. 10000

Enter depositor name for account 3: Sanjay

Enter account number: 456

Enter account type (S for Savings, C for Current): s

Enter initial balance: Rs. 100000

Enter depositor name for account 4: hetanshi

Enter account number: 567

Enter account type (S for Savings, C for Current): c

Enter initial balance: Rs. 1000000

Enter depositor name for account 5: nirva

Enter account number: 678

Enter account type (S for Savings, C for Current): S

Enter initial balance: Rs. 100000000

You might also like