java中如何构造一个修改密码的方法
我需要在下面的基础上增加一个修改密码的方法。。求指点。。packageyezhuzhu;importjava.util.Scanner;classStudent{Stri...
我需要在下面的基础上增加一个修改密码的方法。。求指点。。
package yezhuzhu;
import java.util.Scanner;
class Student
{
String name;
int xuehao;
String sex;
int password;
int room;
int x;
int y;
int z;
public Student(String name,int xuehao,String sex,int password,int room,int x,int y,int z)
{
this.name=name;
this.xuehao=xuehao;
this.sex=sex;
this.password=password;
this.room=room;
this.x=x;
this.y=y;
this.z=z;
}
public Student() {
// TODO Auto-generated constructor stub
}
void show()
{
System.out.println("姓名:"+name);
System.out.println("学号:"+xuehao);
System.out.println("性别:"+sex);
System.out.println("宿舍号:"+room);
System.out.println("密码:"+password);
System.out.println("第一科成绩:"+x);
System.out.println("第二科成绩:"+y);
System.out.println("第三科成绩:"+z);
}
int sum()
{
return x+y+z;
}
double ave()
{
return sum()/3;
}
}
public class Information {
public static void main(String[] args)
{
Student s1 = new Student("yeruiyin",141614237,"man",12345,17306,66,80,90);
s1.show();
System.out.println("成绩总分:"+s1.sum());
System.out.println("成绩平均分:"+s1.ave());
}
} 展开
package yezhuzhu;
import java.util.Scanner;
class Student
{
String name;
int xuehao;
String sex;
int password;
int room;
int x;
int y;
int z;
public Student(String name,int xuehao,String sex,int password,int room,int x,int y,int z)
{
this.name=name;
this.xuehao=xuehao;
this.sex=sex;
this.password=password;
this.room=room;
this.x=x;
this.y=y;
this.z=z;
}
public Student() {
// TODO Auto-generated constructor stub
}
void show()
{
System.out.println("姓名:"+name);
System.out.println("学号:"+xuehao);
System.out.println("性别:"+sex);
System.out.println("宿舍号:"+room);
System.out.println("密码:"+password);
System.out.println("第一科成绩:"+x);
System.out.println("第二科成绩:"+y);
System.out.println("第三科成绩:"+z);
}
int sum()
{
return x+y+z;
}
double ave()
{
return sum()/3;
}
}
public class Information {
public static void main(String[] args)
{
Student s1 = new Student("yeruiyin",141614237,"man",12345,17306,66,80,90);
s1.show();
System.out.println("成绩总分:"+s1.sum());
System.out.println("成绩平均分:"+s1.ave());
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询