You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

LogIn.java 1.1 kB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import java.util.Scanner;
  2. public class LogIn {
  3. public static void main(String[] args) {
  4. //declare variables
  5. String username, password;
  6. int n = 0;
  7. Scanner scanner = new Scanner (System.in);
  8. while (n<3) {
  9. //prompt user for their username
  10. System.out.print("Enter your username: ");
  11. username = scanner.nextLine();
  12. //prompt user for their password
  13. System.out.print("Enter your password: ");
  14. password = scanner.nextLine();
  15. if ("Justinfromcharleston@gmail.com".equals(username) && "secret17".equals(password))
  16. { System.out.println("Welcome " + username + "!!!");
  17. break;
  18. }
  19. else if(!"secret17".equals(password) || !"Justinfromcharleston@gmail.com".equals(username)) {
  20. System.out.println("Incorrect login. Please try again.");
  21. n++;
  22. if (n==3){
  23. System.out.print("Maximum login attemps exceeded.");
  24. break;
  25. }
  26. }
  27. }
  28. }
  29. }

No Description

Contributors (1)