0% found this document useful (0 votes)
16 views

Give me a specific idea with c-- code-1

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Give me a specific idea with c-- code-1

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Let's build a simple ATM simulator using C++:

Core Functionalities:
● Account Creation: Allow users to create new accounts with unique account numbers
and initial balances.
● Deposit Money: Let users deposit money into their accounts.
● Withdraw Money: Enable users to withdraw money from their accounts, considering the
available balance and transaction limits.
● Check Balance: Display the current balance of a specific account.
C++ Code Implementation:
#include <iostream>
#include <vector>

using namespace std;

class Account {
public:
int accountNumber;
double balance;

Account(int accountNumber, double balance) {


this->accountNumber = accountNumber;
this->balance = balance;
}

void deposit(double amount) {


balance += amount;
cout << "Deposited: $" << amount << endl;
}

void withdraw(double amount) {


if (amount <= balance) {
balance -= amount;
cout << "Withdrawn: $" << amount << endl;
} else {
cout << "Insufficient balance!" << endl;
}
}

void checkBalance() {
cout << "Current balance: $" << balance << endl;
}
};

int main() {
vector<Account> accounts;

// Create some sample accounts


accounts.push_back(Account(1234, 1000));
accounts.push_back(Account(5678, 2000));

int choice, accountNumber;


double amount;

while (true) {
cout << "\nATM Menu:\n";
cout << "1. Create Account\n";
cout << "2. Deposit Money\n";
cout << "3. Withdraw Money\n";
cout << "4. Check Balance\n";
cout << "5. Exit\n";
cout << "Enter your choice: ";
cin >> choice;

switch (choice) {
case 1:
// Implement account creation logic
break;
case 2:
cout << "Enter account number: ";
cin >> accountNumber;
cout << "Enter amount to deposit: ";
cin >> amount;
for (Account& account : accounts) {
if (account.accountNumber == accountNumber) {
account.deposit(amount);
break;
}
}
break;
case 3:
// Implement withdrawal logic
break;
case 4:
// Implement balance check logic
break;
case 5:
exit(0);
default:
cout << "Invalid choice!\n";
}
}

return 0;
}

This is a basic ATM simulator. You can enhance it by adding features like transaction history,
PIN-based authentication, and more complex security measures.
● https://github.com/JoannaKang/today-i-learned
● https://github.com/Santhosh-2226/Bankaccount

You might also like