Advertisement
Guest User

Username/Password Authentication code

a guest
Oct 14th, 2017
2,872
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement