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

Give Me A Specific Idea With C - Code-1

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

Give Me A Specific Idea With C - Code-1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy