Emulation

Untitled

Oct 7th, 2013
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.58 KB | None | 0 0
  1. #include <iostream>
  2. double amount = 100.00;
  3. bool goAgain = true;
  4.  
  5. int main() {
  6. std::cout << "Welcome to the ATM Machine! \n" << "Please Enter Your 4 Digit Pin Number: " << std::endl;
  7. int pinNumber;
  8. std::cin >> pinNumber;
  9.  
  10. if(pinNumber != 1234)
  11. {
  12.     std::cout << "Incorrect Pin Number!" << std::endl;
  13.  
  14. }
  15. else
  16. {
  17.     while(goAgain == true)
  18.     {
  19.     std::cout << "-Deposit [1] \n-Withdraw [2]" << std::endl;
  20.     char option;
  21.     std::cin >> option;
  22.     if(option == '1')
  23.     {
  24.         std::cout << "How much to deposit? " << std::endl;
  25.         double depositAmount;
  26.         std::cin >> depositAmount;
  27.         std::cout << "Your new total is $" << depositAmount + amount << std::endl;
  28.         amount = depositAmount + amount;
  29.         std::cout << "Would you like to make another action? [Y/N]" << std::endl;
  30.         char another;
  31.         std::cin >> another;
  32.         if(another == 'Y')
  33.         {
  34.             goAgain = true;
  35.         }
  36.         if(another != 'Y')
  37.         {
  38.             goAgain = false;
  39.         }
  40.     }
  41.     if(option == '2')
  42.     {
  43.         std::cout << "How much to withdraw? Your total is: $" << amount << std::endl;
  44.         double withdrawAmount;
  45.         std::cin >> withdrawAmount;
  46.         if(withdrawAmount > amount)
  47.         {
  48.             std::cout << "Insufficient Funds" << std::endl;
  49.         }
  50.         else
  51.         {
  52.         std::cout << "Successfully withdrew $" << withdrawAmount << " Your new total is: $" << amount - withdrawAmount << std::endl;
  53.         amount = amount - withdrawAmount;
  54.         std::cout << "Would you like to make another action? [Y/N]" << std::endl;
  55.         char another;
  56.         std::cin >> another;
  57.         if(another == 'Y')
  58.         {
  59.             goAgain = true;
  60.         }
  61.         if(another != 'Y')
  62.         {
  63.             goAgain = false;
  64.         }
  65.         }
  66.     }
  67. }
  68. }
  69.  
  70. return 0;
  71. };
Add Comment
Please, Sign In to add comment