会员注册

该博客详细介绍了如何实现会员注册过程,包括设置用户名最小长度为3,密码最小长度为6,并确保用户在注册时两次输入的密码一致的验证机制。

 实现会员注册,要求用户名长度不小于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();

    }

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值