SHARE
TWEET

Username/Password Authentication code

a guest Oct 14th, 2017 2,621 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * A.C. Silvestri
  3.  * 10/14/2017
  4.  * Username/Password Authentication code
  5.  * Chapter 4 Strings Demo
  6.  */
  7.  
  8. import java.util.Scanner;
  9.  
  10. public class Login {
  11.  
  12.     private static void workTheSystem() {
  13.         System.out.println("You are manipulating the system ...");
  14.     }  
  15.    
  16.     public static void main(String[] args) {
  17.         String username, password;
  18.        
  19.         Scanner input = new Scanner(System.in);
  20.         System.out.print("Enter Username: ");
  21.         username = input.nextLine();
  22.         System.out.print("Enter Password: ");
  23.         password = input.nextLine();
  24.         input.close();
  25.        
  26.         username = username.trim();
  27.         password = password.trim();
  28.        
  29.         if (username.equalsIgnoreCase("admin") &&
  30.             password.equals("12345")) {
  31.             System.out.println("You are authorized to use this system.");
  32.             workTheSystem();
  33.         }
  34.         else {
  35.             System.out.println("Credentials invalid.  Go away.");
  36.         }
  37.        
  38.     }
  39.  
  40. }
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