Group3 ComProg Code
Group3 ComProg Code
Group3 ComProg Code
1. Declares global variable so the password length (which is 8) will be applicable even outside the main.
2. Insert a String in scanner with the name password so that it will be print out and will be analyze by the if-
else condition.
3. The if-else condition is (is_Valid(password)) that uses Boolean as a primitive data type to know if the
password is true or false.
4. After coding the if-else condition, let’s open a new method with its arguments which is the String
password (public static boolean is_Valid(String password)).
5. Open an if conditional statement declaring that the length of the password inputted is less that
the password_length (which is 8 as stated by the global variable). if (password.length() <
password_length)
6. Input the charCount and numCount to make sure that the letters and numbers is indicated and present in
the password. It will be analyze b6 the pass which is the name of the char that is the one who will perform
the analyzation. Also, there is a ++ (increment) to make sure that there’s a presence of numbers and
letters. (correct me if I’m wrong)
7. Open another method with argument – Use Boolean as the returntype to determine if it is true or false. I
mean if there is a letters present.
8. Open another method with argument – Use Boolean as the returntype to determine if it is true or false. I
mean if there is a numbers present.
package Sample;
//To enter any password - import scanner para gumana yung scanner sa main
import java.util.Scanner;
System.out.println(" ");
// Number 2
String password = in.nextLine();
// Number 3
if (is_Valid(password)) {
System.out.println("Password is Valid: " +password);
}
else {
System.out.println("Password is invalid: " +password);
}}
// Number 4
public static boolean is_Valid(String password) {
// Number 5
if (password.length() < password_length)
// Number 6
if (is_Number(pass)) numCount++;
else if (is_Letter(pass)) charCount++;
// return the value if both are not present (correct me if I'm wrong)
else return false;
}
// return the value of charCount and numCount in the if else with the
increment (?)
// this is to make sure that the Letter and Number must be greater than or
equal to 2
return (charCount >= 2 && numCount >= 2);
}
// Number 7
public static boolean is_Letter(char pass) {
// Number 8
public static boolean is_Number(char pass) {
}
}