实现会员注册,要求用户名长度不小于3,密码长度不小于6,若不满足需有提示信息,提示输入有误;注册时两次输入密码必须相同(字符串)。
import java.util.Scanner; public class Mys { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); System.out.println("请输入用户名"); String username=scanner.nextLine(); if(username.length()<3){ System.out.println("用户名长度不能小于3"); } System.out.println("请输入密码:"); String password1=scanner.nextLine(); if (password1.length()<6){ System.out.println("密码长度不能小于6"); } System.out.println("再次输入密码"); String password2=scanner.nextLine(); if (!password1.equals(password2)){ System.out.println("两次密码不一样"); } System.out.println("注册成功"); } }
讯享网


版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/74810.html