实现会员注册,要求用户名长度不小于3,密码长度不小于6,注册时两次输入密码必
须相同 (字符串)
import java.util.Scanner;
class Member //会员
{
String nameid; //用户名
String password; //密码
String password1;
Scanner rdata = new Scanner(System.in);
public void input()
{
System.out.print("请输入用户名:");
nameid = rdata.nextLine();
System.out.print("请输入密码:");
password = rdata.nextLine();
System.out.print("请确认密码:");
password1 = rdata.nextLine();
}
public void show()
{
while(nameid.length()<3||password.equals(password1)==false||password.length()<6)
{
if(nameid.length()<3)
{
System.out.println("用户名不小于3个字符!");
}
if(password.equals(password1)==false)
{
System.out.println("请输入相同的密码!");
}
if(password.length()<6)
{
System.out.println("密码不能小于6位!");
}
input();
}
System.out.print("注册成功!");
}
}
public class xiti_5 {
public static void main(String[] args) {
Member h1 = new Member();
h1.input();
h1.show();
}
}
该博客详细介绍了如何实现会员注册过程,包括设置用户名最小长度为3,密码最小长度为6,并确保用户在注册时两次输入的密码一致的验证机制。

1296

被折叠的 条评论
为什么被折叠?



