Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- double amount = 100.00;
- bool goAgain = true;
- int main() {
- std::cout << "Welcome to the ATM Machine! \n" << "Please Enter Your 4 Digit Pin Number: " << std::endl;
- int pinNumber;
- std::cin >> pinNumber;
- if(pinNumber != 1234)
- {
- std::cout << "Incorrect Pin Number!" << std::endl;
- }
- else
- {
- while(goAgain == true)
- {
- std::cout << "-Deposit [1] \n-Withdraw [2]" << std::endl;
- char option;
- std::cin >> option;
- if(option == '1')
- {
- std::cout << "How much to deposit? " << std::endl;
- double depositAmount;
- std::cin >> depositAmount;
- std::cout << "Your new total is $" << depositAmount + amount << std::endl;
- amount = depositAmount + amount;
- std::cout << "Would you like to make another action? [Y/N]" << std::endl;
- char another;
- std::cin >> another;
- if(another == 'Y')
- {
- goAgain = true;
- }
- if(another != 'Y')
- {
- goAgain = false;
- }
- }
- if(option == '2')
- {
- std::cout << "How much to withdraw? Your total is: $" << amount << std::endl;
- double withdrawAmount;
- std::cin >> withdrawAmount;
- if(withdrawAmount > amount)
- {
- std::cout << "Insufficient Funds" << std::endl;
- }
- else
- {
- std::cout << "Successfully withdrew $" << withdrawAmount << " Your new total is: $" << amount - withdrawAmount << std::endl;
- amount = amount - withdrawAmount;
- std::cout << "Would you like to make another action? [Y/N]" << std::endl;
- char another;
- std::cin >> another;
- if(another == 'Y')
- {
- goAgain = true;
- }
- if(another != 'Y')
- {
- goAgain = false;
- }
- }
- }
- }
- }
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement