Advertisement
Guest User

exception

a guest
Dec 12th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include<cstdlib>
  2. #include<iostream>
  3.  
  4. using namespace std;
  5.  
  6. static string login1()
  7. {
  8.     string pengguna;
  9.     cout<<"Masukkan username: ";
  10.     cin>>pengguna;
  11.     return pengguna;
  12. }
  13.     static string login2()
  14.  {  
  15.         string id;
  16.         cout<<"Masukkan Id: ";
  17.         cin>> id;
  18.         return id;
  19. }
  20.     static void konfigurasi (string user, string password)
  21.     {
  22.         bool error;error = true;
  23.         while (error==true);
  24.         {  
  25.             try
  26.             {  
  27.                 while (user !="nama" || password !="nim")
  28.                 {  
  29.                     cout<<endl;
  30.                     cout<< "**Login Failed**";
  31.                     cout<<endl;
  32.                     user = login1();
  33.                     password = login2();
  34.                 }
  35.                 error = false;
  36.             }
  37.            
  38.             catch (exception e)
  39.             {
  40.                 cout<<endl;
  41.                 cout<<"#user & pasword salah:"<<endl;
  42.                 cout<<endl;
  43.             }
  44.         }
  45.     }  
  46.    
  47.     int main (int argc, char*argv[])
  48.     {
  49.         string user,password;
  50.         user = login1();
  51.         password= login2();
  52.         konfigurasi (user,password);
  53.         cout<<endl;
  54.         cout<<" **selamat login sukses** :"<<endl;
  55.         cout<<endl;
  56.         return 0;
  57.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement