package student;
import java.util.*;
public class student {
Scanner sc=new Scanner(System.in);
private String stunumber; //學生學号8位
private String name; //學生姓名
private int age; //學生年齡
private boolean sex; //學生性别
private double score; //學生成績
student()
{
System.out.println("請輸入學生的姓名,年齡,性别,學号,成績!");
setName();
setAge();
setSex();
setNum();
setScore();
}
String getNum()
{
return stunumber;
}
String getName()
{
return name;
}
int getAge()
{
return age;
}
boolean getSex()
{
return sex;
}
double getScore()
{
return score;
}
void setNum()
{
stunumber=sc.next();
sc.close();
}
void setScore()
{
score=sc.nextDouble();
sc.close();
}
void setSex()
{
sex=sc.hasNextBoolean();
sc.close();
}
void setName()
{
name=sc.next();
sc.close();
}
void setAge()
{
age=sc.nextInt();
sc.close();
}
void showStudent()
//列印所有學生資訊
{
System.out.println("姓名:"+name+" 性别:"
+sex+" 年齡:"+age+" 學号:"
+stunumber+" 成績:"+score);
System.out.print("--------------------------------------\n");
}
boolean seclectStudent(String stunumber)
{
//查詢并輸出學生資訊;
String NUM=getNum();
boolean flag = false;
if(NUM==stunumber)
{
System.out.println("已經找到學号為:"+getNum()+"的同學,資訊如下:");
System.out.println("姓名:"+getName()+" 年齡:"+getAge()+" 性别:"
+getSex()+" 學号:"+getScore()+" 成績:"+getScore());
System.out.println("--------------------------------------");
flag=true;
return flag;
}
else
return flag;
}
void updateStudent(String stunumber,String name,int
age,boolean sex,double score)
//實作修改學生資訊功能
{
this.age=age;
this.name=name;
this.score=score;
this.sex=sex;
this.stunumber=stunumber;
System.out.println("修改成功!");
}
public static void main(String[] args) {
// TODO 自動生成的方法存根
System.out.println
("****************************************** \r\n" +
"石家莊鐵道大學資訊科學與技術學院 \r\n" +
"學生資訊管理系統 v2.0 \r\n" +
"****************************************** \r\n" +
"1、 周遊輸出學生資訊; \r\n" +
"2、 新學生資訊錄入; \r\n" +
"3、 删除學生資訊; \r\n" +
"4、 修改學生資訊; \r\n" +
"5、 查詢學生資訊; \r\n" +
"****************************************** ");
}
}
好看請贊,養成習慣 :) ,作者:靠譜楊
關于筆者:我可能不是天才,但我會努力成為人才。
更多日常分享盡在我的VX公衆号:小楊的挨踢IT生活