用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字

用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字

请选择技术分类

 *如果你找不到更细的分类,可以选择上级分类
当前位置:云代码 - 技术问答 - Java

编写方法检验一个字符串是否是合法的密码

 悬赏:10|提问者:一只来自南方的鬼|浏览:2258
举报|2017-04-09
public static void main(String[] args){
{
Scanner input = new Scanner(System.in);
System.out.print("please input a code :");
String code = input.nextLine();
int count = 0;
boolean a=false;
boolean b=true;
boolean c=false;


if(code.length()>8)
a = true;
for(int i=0;i<code.length();i++){
char j = code.charAt(i);
if(j<='9'&&j>='0')
count++;
}
if(count>=2)
c = true;
for(int i=0;i<code.length();i++){
char j = code.charAt(i);
if((j<='a'||j>='z')&&(j<='A'||j>='Z')){
b = false;
System.out.println("the code is a "+(a&&b&&c)+" code");
System.exit(0);
}
}


System.out.println("the code is a "+(a&&b&&c)+" code");
}
}
}

哪错了? 

我来回答

所有回答
举报|(0)|(0)2017-04-12
...
举报|(0)|(0)2017-04-14
三国杀归属感
举报|(0)|(0)2017-04-17
import java.util.Scanner;

public class asd{
public static void main(String[] args){
 
 {
 Scanner input = new Scanner(System.in);
 System.out.print("please input a code :");
 String code = input.nextLine();
 int count = 0;
 boolean a=false;
 boolean b=true;
 boolean c=false;


 if(code.length()>8)
 a = true;
 for(int i=0;i<code.length();i++){
 char j = code.charAt(i);
 if(j<='9'&&j>='0')
 count++;
 }
 if(count>=2)
 c = true;
 for(int i=0;i<code.length();i++){
 char j = code.charAt(i);
 if((j<='a'||j>='z')&&(j<='A'||j>='Z')){
 b = false;
 System.out.println("the code is a "+(a&&b&&c)+" code");
 System.exit(0);
 }
 }


 System.out.println("the code is a "+(a&&b&&c)+" code");
 }
 }
 }

举报|(0)|(0)2017-04-17
??
举报|(0)|(0)2017-06-11
阿斯蒂芬撒
举报|(0)|(0)2017-06-21
111
举报|(0)|(0)2017-07-14
正则一下搞定
#8lbq
举报|(0)|(0)2017-09-13
lihai
举报|(0)|(0)2018-01-09
举报|(0)|(0)2018-02-08
??
举报|(0)|(0)2018-03-13
正则表达式
举报|(0)|(0)2018-04-21
。。。。。
举报|(0)|(0)2018-08-16
举报|(0)|(0)2018-11-15
..
举报|(0)|(0)2019-05-25
QS
举报|(0)|(0)2019-06-02
212
举报|(0)|(0)2019-07-29
年12能1
举报|(0)|(0)2019-10-27
看不出来
举报|(0)|(0)2019-11-02
真三国无双
举报|(0)|(0)2020-05-07
sd
举报|(0)|(0)2020-10-16
6
举报|(0)|(0)2022-01-13
import java.util.Scanner;

public class asd{
public static void main(String[] args){
 
 {
 Scanner input = new Scanner(System.in);
 System.out.print("please input a code :");
 String code = input.nextLine();
 int count = 0;
 boolean a=false;
 boolean b=true;
 boolean c=false;


 if(code.length()>8)
 a = true;
 for(int i=0;i<code.length();i++){
 char j = code.charAt(i);
 if(j<='9'&&j>='0')
 count++;
 }
 if(count>=2)
 c = true;
 for(int i=0;i<code.length();i++){
 char j = code.charAt(i);
 if((j<='a'||j>='z')&&(j<='A'||j>='Z')){
 b = false;
 System.out.println("the code is a "+(a&&b&&c)+" code");
 System.exit(0);
 }
 }


 System.out.println("the code is a "+(a&&b&&c)+" code");
 }
 }
 }

相关提问