Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package candy;
- import java.util.Scanner;
- /**
- *
- * @author rahul
- */
- public class login {
- public void login () {
- int countDigit=0 , countLetter=0 ;
- boolean valid= false;
- boolean match= false;
- Scanner input = new Scanner(System.in);
- System.out.println("Welcome Loyal Customer! Please enter username: ");
- String username = input.nextLine();
- System.out.println("and 3 letter/3 digit Password: ");
- String password1 = input.nextLine();
- while(valid == false){
- if(password1.length()<6 || password1.length()>10){
- valid=false;
- }
- else{
- for(int x = 0;x < password1.length(); x++){
- if(Character.isDigit(password1.charAt(x)))
- countDigit++;
- }
- for(int x = 0; x < password1.length(); x++){
- if(Character.isLetter(password1.charAt(x)))
- countLetter++;
- }
- }
- if(countDigit >=2 && countLetter >=2){
- System.out.println("Valid Password ");
- valid = true;
- System.out.println("Plaese re-enter your passord ");
- String password2 = input.nextLine();
- while(match == false){
- if(password1.equals(password2)){
- match = true;
- System.out.println("Welcome");
- System.out.println("------------------------------------");
- System.out.println("");
- salesMod method1 = new salesMod ();
- method1.salesMod();
- }
- else{
- System.out.println("password does not match");
- System.out.println("Please re-enter your passord");
- password2=input.nextLine();
- match = false;
- }
- }
- }
- else{
- System.out.println("invalid password");
- valid = false;
- System.out.println("Enter password");
- password1 = input.nextLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement