SO i was given this mini project but im stuck. (manage to get an extension for another three days)
(To run in command prompt only)
Ive searched high and low for the codes and tips but i could seem to find any useful ones. even if i did, i wont know how and where to apply them.
these are the criteria needed the this user and pass :
(completed)--> User id should be at least 6 characters long, no digit is allowed.
(incomplete)--> User’s password should be at least 6 alphanumeric long and contains at least one uppercase and at least one lowercase letter.(using if (Charcter.isLetter(yourCharacter)) and if(Character.isDigit(yourCharacter)))
(Completed)--> User’s password should have at least one digit number but password shouldn’t be started up with digit.(using if(Character.isLowerCase(yourCharacter)) and if(Character.isUpperCase(yourCharacter)))
MY problem
--> i have no idea where to insert those codes at all. It my first "mini project" with such little knowledge that i have.
SO far, this is what i got...: (could anyone help me out here?)
import java.util.Scanner; public class Assign3{ public static void main (String [] args){ Scanner input = new Scanner(System.in); //call the method System.out.println("Welcome to Amazon.com"); System.out.println("\nPress ENTER to continue"); String letters = input.nextLine(); System.out.println("Criteria"); System.out.println(); System.out.println("Criteria For ID: \n1.must be at least 6 characters long. \n2.in alphabets only."); System.out.println(); System.out.println("Criteria For Password: \n1.at least 6 alphanumeric long and contains at least one uppercase and at least one lowercase letter. \n2.at least one digit number but password shouldn’t be started up with digit."); System.out.println(); //ID String user_id = enterUserID(); while(!checkUserID(user_id)){ System.out.println("ID does not matches the criteria.Please re-enter"); user_id = enterUserID(); } //Pass String user_pa = enterUserPA(); while(!checkUserPA(user_pa)){ System.out.println("PASSWORD does not matches the criteria.Please re-enter"); user_pa = enterUserPA(); } //Accept System.out.println("ID and PASSWORD is accepted."); } //Entering userID public static String enterUserID(){ String user_id; Scanner input = new Scanner(System.in); System.out.print("ID: "); user_id = input.nextLine(); return user_id; } //Entering userPA public static String enterUserPA(){ String user_pa; Scanner input = new Scanner(System.in); System.out.print("Password: "); user_pa = input.nextLine(); return user_pa; } //ID check public static boolean checkUserID(String user_id){ int length; length = user_id.length(); if (length < 6 || length > 99999){ return false; } for (int i = 0; i < user_id.length();i++){ if (!Character.isLetter(user_id.charAt(i))) return false; } return true; } //PA check public static boolean checkUserPA(String user_pa){ int length; length = user_pa.length(); if (length < 6 || length > 99999){ return false; } for(int i = 0; i < user_pa.length();i++){ for(int i = 0; i < user_pa.length();i++){ if(Character.isDigit(user_pa.charAt(0))) if(!Character.isLetter(user_pa.charAt(i))) if(Character.isUpperCase(user_pa.charAt(0))) if(Character.isLowerCase(user_pa.charAt(0))) return false; } return true; } }