Advertisement
domesticallyevil

Java Code #2 (With some explaination)

Aug 6th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. import java.util.Scanner; //this imports the java scanner we need
  2.  
  3. class login {
  4. public static void main(String args[]){ //sorry this is too long to explain
  5. Scanner luci = new Scanner(System.in); //this makes the scanner usable
  6. String idInput; //creates a string called idInput
  7. System.out.println("Please type Username: "); //tells us to type the username
  8. idInput = luci.nextLine(); //this stores whatever we type in the string
  9. String passwordInput; // creates the password string
  10. System.out.print("Please type Password: "); //tells us to input password
  11. passwordInput = luci.nextLine(); //set whatever we inputed to the string passwordInput
  12.  
  13.  
  14. if(passwordInput.equals("password") && (idInput.equals("alex"))){ //this checks what
  15. //is stored in passwordInput and idInput and if pass is = to : password and id is = to: alex
  16. //then type
  17.  
  18. System.out.println("Login complete!"); //this here <--
  19.  
  20. }else{ //if the password or username are wrong or both wrong type the correct ones
  21. System.out.println("Wrong Username or Password!");
  22.  
  23.  
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement