SHARE
TWEET

cnd

a guest Jun 11th, 2019 127 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.     char pilihan, q;
  6.     string username, password;
  7.  
  8.     cout << "=== Welcome ===" << endl;
  9.     cout << "Username: ";
  10.     cin >> username;
  11.     cout << "Password: ";
  12.     cin >> password;
  13.  
  14.     if (username == "admin"){
  15.         if (password == "final"){
  16.             cout << "Selamat datang!" << endl;
  17.         } else {
  18.             cout << "Password salah, coba lagi!" << endl;
  19.         }
  20.     } else {
  21.         cout << "Anda tidak terdaftar" << endl;
  22.     }
  23.  
  24. menu:
  25.     cout << "1. ip" << endl;
  26.     cout << "2. test" << endl;
  27.     cin >> pilihan;
  28.    
  29. switch(pilihan){
  30. case '1':
  31.             int a[4],i=0;
  32.  
  33.         cout<<"Masukkan IP address: ";
  34.         for(i=0;i<4;i++)
  35.                 cin>>a[i];
  36.  
  37.         cout<<"\n IP Address:"<<a[0];
  38.         cout<<"."<<a[1]<<"."<<a[2]<<"."<<a[3]<<"\n";
  39.  
  40.         cout<<"Ini Termasuk IP Address: ";
  41.  
  42.         if(a[0]>=0 && a[0]<=127)
  43.         cout << "Class A" << endl;
  44.         if(a[0]>127 && a[0]<191)
  45.         cout << "Class B" << endl;
  46.         if(a[0]>191 && a[0]<224)
  47.         cout << "Class C";
  48.         if(a[0]>224 && a[0]<=239)
  49.         cout  <<"Class D" << endl;
  50.         if(a[0]>239)
  51.         cout << "Class E" << endl;
  52.        
  53.     std::cout << "Apakah anda Ingin lagi? [Y/N]";
  54.     std::cin >> q;  
  55.    
  56.     if(q == 'Y' || q == 'y')
  57.     {
  58.         goto menu;
  59.     }else if ( q == 'N' || q == 'n'){
  60.         goto finish;
  61.     }else {
  62.         goto finish;
  63.     }
  64.      cin.get();
  65.      break;  
  66.  
  67. case '2':
  68.             cout << "test" << endl;
  69.  
  70.     std::cout << "Apakah anda Ingin lagi? [Y/N]";
  71.     std::cin >> q;  
  72.    
  73.     if(q == 'Y' || q == 'y')
  74.     {
  75.         goto menu;
  76.     }else if ( q == 'N' || q == 'n'){
  77.         goto finish;
  78.     }
  79.      cin.get();
  80.      break;
  81.  
  82. }
  83.  
  84. return 0;
  85. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top