Advertisement
Guest User

Untitled

a guest
Oct 11th, 2018
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Project {
  4.  
  5. public static void main(String[] args) {
  6. // TODO Auto-generated method stub
  7. String[][] names= new String[1000][1000];
  8.  
  9. Scanner myScanner= new Scanner(System.in);
  10. String Username, password;
  11. boolean checkPoint1=false, checkPoint2=false, checkPoint3=false;
  12. //Usernames
  13. names[0][0]= "Username1";
  14. names[0][1]= "Username2";
  15. names[0][2]= "Username3";
  16. names[0][3]= "Username4";
  17. names[0][4]= "Username5";
  18.  
  19. //Passwords
  20. names[1][0]= "Password1";
  21. names[1][1]= "Password2";
  22. names[1][2]= "Password3";
  23. names[1][3]= "Password4";
  24. names[1][4]= "Password5";
  25.  
  26. //Prompt User for Username
  27.  
  28. System.out.println("What is the Username?");
  29. Username=myScanner.nextLine();
  30. System.out.println("What is the Password");
  31. password=myScanner.nextLine();
  32.  
  33.  
  34. for(int i=0; i<5; i++) {
  35. if(Username.equals(names[0][i]))
  36. {
  37. checkPoint1=true;
  38. if(checkPoint1==true)
  39. System.out.println();
  40. else
  41. if(checkPoint1==false) {
  42. System.out.println("Wrong Username");
  43.  
  44. }
  45.  
  46. for(int k=0; k<5; k++)
  47. if(password.equals(names[k][i]))
  48. checkPoint2=true;
  49. if(checkPoint2==true) {
  50. System.out.println();
  51. checkPoint3=true;
  52. }
  53. }
  54.  
  55. }
  56.  
  57. //Password
  58.  
  59. if(checkPoint3==true) {
  60. System.out.println("Welcome");
  61.  
  62. }
  63. else
  64. System.out.println("Wrong Username or Password");
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement