Advertisement
Guest User

Untitled

a guest
Sep 9th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Login {
  4. public static void main(String[] args) {
  5. String username, usernameInput;
  6. int password, passwordInput;
  7. boolean login = false;
  8. Scanner input = new Scanner(System.in);
  9. Scanner enter = new Scanner(System.in);
  10. System.out.print("Please enter a desired username: ");
  11. username = input.nextLine();
  12. System.out.print("Please enter a desired password: ");
  13. password = enter.nextInt();
  14. System.out.println("Log in:");
  15. while (login == false) {
  16. System.out.print("Please enter your username: ");
  17. usernameInput = input.nextLine();
  18. System.out.print("Please enter your password: ");
  19. passwordInput = enter.nextInt();
  20. if (username.equals(usernameInput) && password == passwordInput) {
  21. System.out.println("You have successfully logged in!");
  22. login = true;
  23. }
  24. else {
  25. System.out.println("Login unsuccessful... try again");
  26. }
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement