Advertisement
Guest User

Untitled

a guest
Sep 16th, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. package candy;
  2. import java.util.Scanner;
  3. /**
  4. *
  5. * @author rahul
  6. */
  7.  
  8. public class login {
  9. public void login () {
  10. int countDigit=0 , countLetter=0 ;
  11. boolean valid= false;
  12. boolean match= false;
  13.  
  14. Scanner input = new Scanner(System.in);
  15.  
  16. System.out.println("Welcome Loyal Customer! Please enter username: ");
  17. String username = input.nextLine();
  18.  
  19.  
  20. System.out.println("and 3 letter/3 digit Password: ");
  21. String password1 = input.nextLine();
  22.  
  23.  
  24. while(valid == false){
  25. if(password1.length()<6 || password1.length()>10){
  26. valid=false;
  27. }
  28.  
  29. else{
  30. for(int x = 0;x < password1.length(); x++){
  31. if(Character.isDigit(password1.charAt(x)))
  32. countDigit++;
  33. }
  34. for(int x = 0; x < password1.length(); x++){
  35. if(Character.isLetter(password1.charAt(x)))
  36. countLetter++;
  37. }
  38. }
  39. if(countDigit >=2 && countLetter >=2){
  40. System.out.println("Valid Password ");
  41. valid = true;
  42. System.out.println("Plaese re-enter your passord ");
  43. String password2 = input.nextLine();
  44.  
  45. while(match == false){
  46. if(password1.equals(password2)){
  47. match = true;
  48. System.out.println("Welcome");
  49. System.out.println("------------------------------------");
  50. System.out.println("");
  51.  
  52.  
  53. salesMod method1 = new salesMod ();
  54. method1.salesMod();
  55.  
  56. }
  57. else{
  58. System.out.println("password does not match");
  59. System.out.println("Please re-enter your passord");
  60. password2=input.nextLine();
  61. match = false;
  62. }
  63. }
  64. }
  65. else{
  66. System.out.println("invalid password");
  67. valid = false;
  68. System.out.println("Enter password");
  69. password1 = input.nextLine();
  70. }
  71.  
  72.  
  73. }
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement