Saturday, March 23, 2013

Contoh Program ATM dgn Borland C++

 Heloo guys,, ini sya share aja..

 ================
#include <conio.h>
#include <iostream.h>
#include <string>

void main()
{
   string pin;
   char salahpin;
   do
   {
       clrscr();
        cout<<"===============================\n";
      cout<<"          Bank Arifin\n";
      cout<<"===============================\n";
      cout<<"     PIN  : ";cin>>pin;
      if(pin!="050788")
      {
            cout<<endl;
            cout<<"PIN yang anda masukkan salah\n";
            cout<<"Silahkan dicoba lagi\n";
         salahpin='1';
            getch();
      }
      else
      {
          int saldo=0;
          char ulang='Y';
          int pilihan=0;
          int nabung=0;
          int tarik=0;

          do
          {
                  nabung=0;
               tarik =0;
               salahpin='0';
               clrscr();
               cout<<"===============================\n";
                  cout<<"          Bank Arifin\n";
                  cout<<"===============================\n";
                  cout<<"     1. Menabung\n";
               cout<<"     2. Penarikan\n";
               cout<<"     3. Cek Saldo\n";
               cout<<"     4. Keluar\n";
               cout<<"===============================\n";
               cout<<"     Pilihan : ";cin>>pilihan;
               cout<<endl;
               switch (pilihan)
               {
                   case 1:
                  {
                      clrscr();
                     cout<<"===================================================\n";
                          cout<<"                    Bank Arifin\n";
                          cout<<"===================================================\n";
                     cout<<"   Masukkan Nominal Nabung : ";cin>>nabung;
                     clrscr();
                     cout<<"===================================================\n";
                          cout<<"                    Bank Arifin\n";
                          cout<<"===================================================\n";
                     cout<<"   Proses Berhasil Menabung Sebesar Rp "<<nabung<<endl;
                     cout<<endl;
                     cout<<endl;
                     saldo+=nabung;
                     cout<<"   Ada Transaksi Lain [Y/N] : ";cin>>ulang;
                     break;
                  }
                  case 2:
                  {
                      clrscr();
                     cout<<"===================================================\n";
                          cout<<"                    Bank Arifin\n";
                          cout<<"===================================================\n";
                     cout<<"   Masukkan Nominal Penarikan : ";cin>>tarik;
                     cout<<endl;
                     if(saldo < 50000)
                     {
                         cout<<"   Saldo tidak mencukupi untuk melakukan penarikan"<<endl<<endl;
                        cout<<"   Ada Transaksi Lain [Y/N] : ";cin>>ulang;
                     }
                     else if(tarik>saldo)
                     {
                        cout<<"   Saldo anda tidak mencukupi"<<endl<<endl;
                        cout<<"   Sisa Saldo Anda Rp "<<saldo<<endl;
                        cout<<"   Ada Transaksi Lain [Y/N] : ";cin>>ulang;
                     }
                     else if((saldo-tarik)<10000)
                     {
                        cout<<"   Jumlah penarikan tidak bisa dilakukan"<<endl<<endl;
                        cout<<"   Saldo anda tidak mencukupi "<<saldo<<endl;
                        cout<<"   Ada Transaksi Lain [Y/N] : ";cin>>ulang;
                        break;
                     }
                     else if((tarik % 50000) != 0 )
                     {

                         cout<<"   Jumlah penarikan tidak bisa dilakukan "<<endl<<endl;
                        cout<<"   Keliptan Rp 50.000,- atau Rp 100.000,-"<<endl<<endl;
                        cout<<"   Ada Transaksi Lain [Y/N] : ";cin>>ulang;
                     }
                     else if(tarik >5000000 )
                     {

                         cout<<"   Jumlah penarikan tidak bisa dilakukan maksimum Rp 5.000.000,- /hari"<<endl<<endl;
                        cout<<"   Ada Transaksi Lain [Y/N] : ";cin>>ulang;
                     }

                     else
                     {
                         cout<<"   Proses Penarikan Berhasil "<<endl;
                        saldo-=tarik;
                        cout<<"   Sisa Saldo Anda Rp "<<saldo<<endl;
                        cout<<"   Ada Transaksi Lain [Y/N] : ";cin>>ulang;
                     }
                     break;
                  }
                  case 3:
                  {
                     clrscr();
                     cout<<"===================================================\n";
                          cout<<"                    Bank Arifin\n";
                          cout<<"===================================================\n";
                     cout<<"   Jumlah Saldo Akhir Rp "<<saldo<<endl<<endl;
                     cout<<"   Ada Transaksi Lain [Y/N] : ";cin>>ulang;
                     break;

                  }
                  case 4:
                  {
                      ulang = 'n';
                     break;
                  }
                  default :
                  {
                     clrscr();
                     cout<<"   Pilihan tidak ada"<<endl<<endl;
                     cout<<"   Ada Transaksi Lain [Y/N] : ";cin>>ulang;
                     break;

                  }
               }
                //cout<<ulang<<endl<<salahpin;

               //getch();
                if(ulang == 'N') ulang= 'n';

          }while ((ulang!='n')) ;

      }
   }while(salahpin!='0');

}

4 comments: