java怎么实现修改用户名密码
2016-07-22 · 百度知道合伙人官方认证企业
import java.util.Scanner;
public class Administrator{
String name;//姓名
String password;//密码
String inputpass;//判断是否正确的密码
String newpassword;//再次输入密码
String repassword;//第2输入的密码
//String admin="";
String inputname="";
String Administrator ;
//显示方法
public void show(){
System.out.println("请输入用户名:");
Scanner input =new Scanner(System.in);
inputname =input.next();
System.out.println("请输入密码:");
inputpass=input.next();
if(inputname.equals(name)&inputpass.equals(password)){
System.out.println("请输入新密码:");
newpassword=input.next();
System.out.println("请确认新密码:");
repassword=input.next();
while(!(newpassword.equals(repassword))){
System.out.println("两次输入的密码不一致,请重新输入新密码:");
newpassword=input.next();
System.out.println("请确认新密码:");
repassword=input.next();
}System.out.println("修改密码成功,新密码是:"+repassword);
}else{
System.out.println("用户名密码不一致,没更新的权限");
}
}
}
package changepassword;
public class AdministratorTest {
public static void main(String[] args) {
Administrator admin=new Administrator();//创建对象
admin.name="admin1";
admin.password="111111";
admin.show();
}
}
package changepassword;
import java.util.Scanner;
public class Administrator{
String name;//姓名
String password;//密码
String inputpass;//判断是否正确的密码
String newpassword;//再次输入密码
String repassword;//第2输入的密码
//String admin="";
String inputname="";
String Administrator ;
//显示方法
public void show(){
System.out.println("请输入用户名:");
Scanner input =new Scanner(System.in);
inputname =input.next();
System.out.println("请输入密码:");
inputpass=input.next();
if(inputname.equals(name)&inputpass.equals(password)){
System.out.println("请输入新密码:");
newpassword=input.next();
System.out.println("请确认新密码:");
repassword=input.next();
while(!(newpassword.equals(repassword))){
System.out.println("两次输入的密码不一致,请重新输入新密码:");
newpassword=input.next();
System.out.println("请确认新密码:");
repassword=input.next();
}System.out.println("修改密码成功,新密码是:"+repassword);
}else{
System.out.println("用户名密码不一致,没更新的权限");
package changepassword;
public class AdministratorTest {
public static void main(String[] args)
{ Administrator admin=new Administrator();//创建对象
admin.name="admin1";
admin.password="111111";
admin.show();}