Free Aang Cursors at www.totallyfreecursors.com

Senin, 16 Februari 2015

Automated Teller Machine (ATM) in C++


#include <stdlib.h>
#include <conio.h>
#include <iostream>
using namespace std;
main() {

   double balance = 0, deposit = 0, withdraw = 0;

   menu:
   system("cls");
   // Menu
   cout << " -----------------------------------------------------------------------  \n";
   cout << "|                        AUTOMATED TELLER MACHINE                       | \n";
   cout << " ----------------- ----------------- ----------------- -----------------  \n";
   cout << "|                 |                 |                 |                 | \n";
   cout << "| Balance Inquiry |     Deposit     |    Withdraw     |      Quit       | \n";
   cout << "|      Press a    |     Press b     |     Press c     |     Press d     | \n";
   cout << "|                 |                 |                 |                 | \n";
   cout << " ----------------- ----------------- ----------------- -----------------  \n";

   switch(getch()) {
       case 'a':
           system("cls");
           // Balance Inquiry
           cout << " -----------------------------------------------------------------------  \n";
           cout << "|                        AUTOMATED TELLER MACHINE                       | \n";
           cout << " -----------------------------------------------------------------------  \n";
           cout << "| Balance Inquiry:                                                      | \n";
           cout << "| Your current balance is:" << balance << "                                             | \n";
           cout << "|                                                                       | \n";
           cout << "|                                                                       | \n";
           cout << " -----------------------------------------------------------------------  \n";

           system("pause");
           goto menu;

       case 'b':
           system("cls");
           // Deposit
           cout << " -----------------------------------------------------------------------  \n";
           cout << "|                        AUTOMATED TELLER MACHINE                       | \n";
           cout << " -----------------------------------------------------------------------  \n";
           cout << "| Deposit:                                                              | \n";
           cout << " -----------------------------------------------------------------------  \n";
           cin  >> deposit;
           balance = balance + deposit;
           system("cls");
           // Balance Inquiry
           cout << " -----------------------------------------------------------------------  \n";
           cout << "|                        AUTOMATED TELLER MACHINE                       | \n";
           cout << " ----------------------------------- -----------------------------------  \n";
           cout << "| Balance Inquiry:                                                      | \n";
           cout << "| Your current balance is:" << balance << "                                             | \n";
           cout << "|                                                                       | \n";
           cout << "|                                                                       | \n";
           cout << " -----------------------------------------------------------------------  \n";

           system("pause");
           goto menu;

        case 'c':
           system("cls");
           // Withdraw
           cout << " -----------------------------------------------------------------------  \n";
           cout << "|                        AUTOMATED TELLER MACHINE                       | \n";
           cout << " ----------------------------------- -----------------------------------  \n";
           cout << "| Withdraw:                                                              | \n";
           cout << " -----------------------------------------------------------------------  \n";
           cin >> withdraw;
           balance = balance - withdraw;

           system("cls");

           // Balance Inquiry
           cout << " -----------------------------------------------------------------------  \n";
           cout << "|                        AUTOMATED TELLER MACHINE                       | \n";
           cout << " -----------------------------------------------------------------------  \n";
           cout << "| Balance Inquiry:                                                      | \n";
           cout << "| Your current balance is:" << balance << "                                             | \n";
           cout << "|                                                                       | \n";
           cout << "|                                                                       | \n";
           cout << " -----------------------------------------------------------------------  \n";

           system("pause");
           goto menu;

        case 'd':
           system("cls");
           // Quit
           cout << " -----------------------------------------------------------------------  \n";
           cout << "|                        AUTOMATED TELLER MACHINE                       | \n";
           cout << " -----------------------------------------------------------------------  \n";
           cout << "|                                                                       | \n";
           cout << "|                      Thank you for banking with us!                   | \n";
           cout << "|                                                                       | \n";
           cout << "|                                                                       | \n";
           cout << " -----------------------------------------------------------------------  \n";

           break;
        default:
           goto menu;

   }

}

Tidak ada komentar:

Posting Komentar