0% found this document useful (0 votes)
4 views2 pages

Dadad

This document is a C++ program that simulates an ATM system. It allows users to check their balance, withdraw, and deposit money after entering a correct PIN. If the PIN is incorrect, access is denied.
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)
4 views2 pages

Dadad

This document is a C++ program that simulates an ATM system. It allows users to check their balance, withdraw, and deposit money after entering a correct PIN. If the PIN is incorrect, access is denied.
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/ 2

#include <iostream>

int main() {
int balance = 10000;
int pin, option;
int withdrawAmount, depositAmount;

std::cout << "Welcome to the ATM!" << std::endl;

// PIN verification
std::cout << "Enter your PIN: ";
std::cin >> pin;

// Main menu
if (pin == 1234) { // Replace with your desired PIN
do {
std::cout << "\nATM Menu:" << std::endl;
std::cout << "1. Check Balance" << std::endl;
std::cout << "2. Withdraw" << std::endl;
std::cout << "3. Deposit" << std::endl;
std::cout << "4. Exit" << std::endl;
std::cout << "Choose an option: ";
std::cin >> option;

switch (option) {
case 1: // Check Balance
std::cout << "Your balance is $" << balance << std::endl;
break;

case 2: // Withdraw
std::cout << "Enter the amount to withdraw: ";
std::cin >> withdrawAmount;
if (withdrawAmount <= balance) {
balance -= withdrawAmount;
std::cout << "Withdrawal successful. Remaining balance: $"
<< balance << std::endl;
} else {
std::cout << "Insufficient funds!" << std::endl;
}
break;

case 3: // Deposit
std::cout << "Enter the amount to deposit: ";
std::cin >> depositAmount;
balance += depositAmount;
std::cout << "Deposit successful. New balance: $" << balance <<
std::endl;
break;

case 4: // Exit
std::cout << "Thank you for using the ATM. Goodbye!" <<
std::endl;
break;

default:
std::cout << "Invalid option. Please try again." << std::endl;
break;
}
} while (option != 4);
} else {
std::cout << "Incorrect PIN. Access denied." << std::endl;
}

return 0;
}

You might also like