Senin, 25 November 2013

Contoh Pembuatan Program ATM

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{ int i,pin,pilihan;
   
    cout<<"==> SELAMAT DATANG DI ATM ^_^ <=="<<endl;
   
    int pass = 140295;
    i = 1;
    
    do
    {
      
        cout<<"Masukkan Pin Anda: "<<endl;
        cin>>pin;
        if(pin==pass){
                          
        cout<<"==> Selamat anda berhasil masuk di menu ATM <=="<<endl;
        cout<<"1. 100.000\t\t\t5. 1.000.000\t\t\t"<<endl;
        cout<<"2. 200.000\t\t\t6. 2.000.000\t\t\t"<<endl;
        cout<<"3. 300.000\t\t\t7. 5.000.000\t\t\t"<<endl;
        cout<<"4. 500.000\t\t\t8. Lainnya\t\t\t\t"<<endl;
        cin>>pilihan;
        switch(pilihan)
        {case 1:
              {cout<<"100.000"<<endl;}
              break;
        case 2:
              {cout<<"200.000"<<endl;}
              break;
       case 3:
              {cout<<"300.000"<<endl;}
              break;
       case 4:
              {cout<<"500.000"<<endl;}
              break;
       case 5:
              {cout<<"1.000.000"<<endl;}
              break;
       case 6:
              {cout<<"2.000.000"<<endl;}
              break;
       case 7:
              {cout<<"5.000.000"<<endl;}
              break;
       case 8:
              {cout<<"Lainnya ="<<endl;
       cout<<"1. Pembelian Pulsa\t\t\t3. Cek Saldo\t\t\t"<<endl;
       cout<<"2. Transfer\t\t\t\t4. Cancel\t\t\t"<<endl;}
             break;
             
              default:
              cout<<"\a\a\a\a\a\a\a\a\a\a\a\a\a\a\a\a\a\a\a\a...ERROR...."<<endl;
              cout<<"Perintah Yang Anda Masukan Salah"<<endl;}
               
       
         system("PAUSE");
    return EXIT_SUCCESS;
        }else {
              cout<<"Pin anda salah silahkan coba lagi"<<endl;
              i=i+1;
              }
              }                                                                                    
                                        
        while (i<=3);
        cout<<"ATM TERBLOKIR... !!! Segera Hubungi Customer Service "<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}