Software NetBeans IDE 7.0.1, need to write the main class alone.
Packaging a class MyPassword, comprises a method for testing a string parameter is a valid password. Suppose password rules:
(1) The password must be at least eight characters; (2) codes can include letters and numbers; (3) a password must be at least 2 digits.
Packaging executes the main class, passing arguments, it determines if the parameter conform to the rules. Packaging executes the main class.
Main categories:
Mypassword m=new Mypassword();
String c=m.Judge("aa44444ffffff");
System.out.println(c);
MyPassword categories:
public class Mypassword {
public String Judge(String s){
char[] a=s.toCharArray();
int length=a.length;
int i,k=0,j=0;
String b;
for(i=0;i<length;i++){
if((a[i]>='0'&&a[i]<='9')||(a[i]>='A'&&a[i]<='Z')||(a[i]>='a'&&a[i]<='z')){
j++;
if(a[i]>='0'&&a[i]<='9'){
k++;
}
}
}
if(k>=2&&length>=8&&j==length){
b="符合要求";
}
else{
b="不符合要求";
}
return b;
}
}