当前位置:首页 » 编程语言 » java学生信息

java学生信息

发布时间: 2022-09-09 02:55:27

㈠ 用java实现学生信息管理系统

不就是一个c/s架构的,学生信息管理系统嘛,晚上给你发过去。

㈡ Java实现简易学生信息管理系统

使用JFileChooser来选择打开文件, 使用FileInputStream进行读取文件,FileOutputStream来写文件 这些没什么难度吧。中间的显示,你就直接用JFileArea就是了,然后设置为自动换行。

㈢ 用JAVA定义一个学生类Student来表示学生信息,学生类中包含成员有学号(id)、姓名(name)、年龄和成绩

如下所示:

public class Student {
private int sNo; //学号
private String name; //姓名
private String sex; //性别
private int yu; //语文
private int shu; //数学
private int wai; //外语
public int getsNo() {
return sNo;
}
public void setsNo(int sNo) {
this.sNo = sNo;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public int getYu() {
return yu;
}
public void setYu(int yu) {
this.yu = yu;
}
public int getShu() {
return shu;
}
public void setShu(int shu) {
this.shu = shu;
}
public int getWai() {
return wai;
}
public void setWai(int wai) {
this.wai = wai;
}

㈣ JAVA学生信息的输入

正规的写法,创建Student类,要有构造方法,重写toString方法,这个可以改为你需要的格式
public class Student {
private String number;
private String name;
private char sex;
private double[] score=new double[3];
private double ave;
private double sum;

public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public char getSex() {
return sex;
}
public void setSex(char sex) {
this.sex = sex;
}
public double[] getScore() {
return score;
}
public void setScore(double[] score) {
this.score = score;
}
public double getAve() {
return ave;
}
public void setAve(double ave) {
this.ave = ave;
}
public double getSum() {
return sum;
}
public void setSum(double sum) {
this.sum = sum;
}

@Override
public String toString() {
return "Student [number=" + number + ", name=" + name + ", sex=" + sex
+ ", score=" + Arrays.toString(score) + ", ave=" + ave
+ ", sum=" + sum + "]";
}

public Student() {

}

public Student(String number, String name, char sex, double[] score,
double ave, double sum) {
super();
this.number = number;
this.name = name;
this.sex = sex;
this.score = score;
this.ave = ave;
this.sum = sum;
}

然后你另外写一个类,里面有input 和 output方法来操作你的这个学生类。

㈤ 简单的java学生信息管理系统

package bean; public class Student { String name; String studentId; String sex; int grade; public Student(String name,String studentId,String sex,int grade){ this.name= name; this.studentId= studentId; this.sex = sex; this.grade = grade; } public int getGrade(){ return grade; } public String getName(){ return name; } public String getSex(){ return sex; } public void setGrade(int g){ this.grade = g; } public String getStudentId(){ return studentId; } }
System.out.println("***************"); System.out.println("*欢迎来到学生管理系统 *"); System.out.println("*1:增加学生 *"); System.out.println("*2:删除学生 *"); System.out.println("*3:修改成绩 *"); System.out.println("*4:查询成绩 *"); System.out.println("***************"); System.out.println("您想选择的操作是:");
import java.util.*;
Scanner sc = new Scanner(System.in); int choice = sc.nextInt();
package test; import java.util.*; import bean.Student; public class Manager { static List<Student> StudentList = new LinkedList<Student>(); public static void main(String[] agrs){ select(StudentList); } private static void select(List<Student> StudentList ){ System.out.println("***************"); System.out.println("*欢迎来到学生管理系统 *"); System.out.println("*1:增加学生 *"); System.out.println("*2:删除学生 *"); System.out.println("*3:修改成绩 *"); System.out.println("*4:查询成绩 *"); System.out.println("***************"); System.out.println("您想选择的操作是:"); Scanner sc = new Scanner(System.in); int choice = sc.nextInt(); switch(choice){ //增加学生 case 1: System.out.print("请输入学生的姓名:"); Scanner Sname = new Scanner(System.in); String name = Sname.nextLine(); System.out.print("请输入学生的性别:"); Scanner Ssex = new Scanner(System.in); String sex = Ssex.nextLine(); System.out.print("请输入学生的学号:"); Scanner SId = new Scanner(System.in); String studentId = SId.nextLine(); System.out.print("请输入学生的成绩:"); Scanner Sgrade = new Scanner(System.in); int grade = Sgrade.nextInt(); StudentList.add(new Student(name,studentId,sex,grade)); System.out.println("添加成功!!!!!"); select(StudentList); break; //删除学生成绩 case 2: System.out.print("请告诉我需要删除学生的学号:"); Scanner Sid = new Scanner(System.in); String SstudentId = Sid.nextLine(); boolean isfindDelete = false; for (int i = 0; i < StudentList.size(); i++) { if(SstudentId.equals(StudentList.get(i).getStudentId())){ System.out.println("发现了该学生,正在删除..."); StudentList.remove(i); System.out.println("删除成功!!!"); isfindDelete =true; } } if(!isfindDelete){ System.out.println("抱歉,没有找到"); } select(StudentList); break; //修改学生成绩 case 3: System.out.print("请告诉我需要修改成绩学生的学号:"); Scanner GId = new Scanner(System.in); String GstudentId = GId.nextLine(); boolean isfindChange = false; for (int j = 0; j < StudentList.size(); j++) { if(GstudentId.equals(StudentList.get(j).getStudentId())){ System.out.println("发现了该学生,正在修改..."); System.out.println("学生原成绩为"+StudentList.get(j).getGrade()); System.out.print("请输入修改后学生的成绩:"); Scanner Ggrade = new Scanner(System.in); int grade2 = Ggrade.nextInt(); StudentList.get(j).setGrade(grade2); System.out.println("修改成功!!!"); isfindChange =true; }else{ } } if(!isfindChange){ System.out.println("抱歉,没有找到"); } select(StudentList); break; //查看学生成绩 case 4: System.out.print("请告诉我需要查询学生的学号:"); Scanner CId = new Scanner(System.in); String CstudentId = CId.nextLine(); boolean isfindData = false; for (int i = 0; i < StudentList.size(); i++) { if(CstudentId.equals(StudentList.get(i).getStudentId())){ System.out.println("名字:"+StudentList.get(i).getName()); System.out.println("性别:"+StudentList.get(i).getSex()); System.out.println("学号:"+StudentList.get(i).getStudentId()); System.out.println("成绩:"+StudentList.get(i).getGrade()); isfindData = true; } } if(!isfindData){ System.out.println("抱歉,没有找到"); } select(StudentList); break; default: System.out.println("您输入的数字有误,请重新输入:"); break; } } }

㈥ Java:学生信息姓名、学号、成绩。定义一个类,并定义相关的构造函数和方法来设置和获取相关的学生信息

1、代码如下:

Main类

importjava.util.*;

importjava.io.BufferedReader;

importjava.io.InputStreamReader;


/**

*Main主方法

*@authorbufei

*

*/


publicclassMain{


publicstaticvoidmain(String[]args){

stuGrad();

}


publicstaticvoidstuGrad(){

intstuNum=1;

Student[]stu=newStudent[stuNum];

double[]totals=newdouble[stuNum];

Map<Double,Integer>map=newHashMap<>(stuNum);

for(inti=0;i<stuNum;i++){

System.out.println("请输入第"+(i+1)+"个学生信息:");

try{

BufferedReaderreader=newBufferedReader(newInputStreamReader(System.in));

System.out.println("姓名:");

Stringname=reader.readLine();

System.out.println("学号:");

intid=Integer.parseInt(reader.readLine());

System.out.print("语文:");

doubleliterature=Double.parseDouble(reader.readLine());

System.out.print("数学:");

doublemath=Double.parseDouble(reader.readLine());

System.out.print("英语:");

doubleenglish=Double.parseDouble(reader.readLine());

stu[i]=newStudent(name,id,literature,math,english);

totals[i]=stu[i].getTotal();

map.put(stu[i].getTotal(),i);

}catch(Exceptione){

//TODO:handleexception

e.printStackTrace();

}


}

Arrays.sort(totals);

for(intj=stuNum-1;j>=0;j--){

inti=map.get(totals[j]);

System.out.println(stu[i].toString());

}

}

}

2、Student类

publicclassStudent {

private String name;

privateintstuId;

//总分

privatedoubletotal;

privatedoubleenglish;

//数学

privatedoublemathematical;

//文学

privatedoubleliterature;

public String getName(){

return name;

}

public void SetName(String name){

this.name = name;

}

publicintgetStuId(){

returnstuId;

}


publicvoidsetStuId(intstuId){

this.stuId=stuId;

}


publicintgetGrade(){

returngrade;

}


publicvoidsetGrade(intgrade){

this.grade=grade;

}


publicStudent(){

}


publicdoublegetTotal(){

returnthis.english+this.literature+this.mathematical;

}


publicdoublegetEnglish(){

returnenglish;

}


publicvoidsetEnglish(doubleenglish){

this.english=english;

}


publicdoublegetMathematical(){

returnmathematical;

}


publicvoidsetMathematical(doublemathematical){

this.mathematical=mathematical;

}


publicdoublegetLiterature(){

returnliterature;

}


publicvoidsetLiterature(doubleliterature){

this.literature=literature;

}


publicStudent(intstuId,doubletotal,doubleenglish,doublemathematical,doubleliterature){

this.stuId=stuId;

this.total=total;

this.english=english;

this.mathematical=mathematical;

this.literature=literature;

}


publicStudent(Stringname,intstuId,doubleenglish,doublemathematical,doubleliterature){

this.name=name;

this.stuId=stuId;

this.english=english;

this.mathematical=mathematical;

this.literature=literature;

}


@Override

publicStringtoString(){

return"学生"+name +",学号"+stuId+",总分="+getTotal()+"[英语="+english+",语文="

+literature+",数学="+mathematical+"]";

}


}

3、运行效果

㈦ 1. 使用JAVA定义一个表示学生信息的类Student,

publicclassStudent{
privateintid;//表示学号,
privateStringname;//表示姓名,
privateStringsex;//表示性别,
privateintage;//表示年龄,
privatedoublecomputer_score;//表示计算机课程的成绩,
privatedoubleEnglish_score;//表示英语课的成绩,
privatedoubleMaths_score;//表示数学课的成绩,
privatedoubletotal_score;//表示总成绩,
privatedoubleave_score;//表示平均成绩。

//自动生成getset方法
public...get...

publicvoidset...
}

㈧ 要求编写一个java程序,输入学生信息,并能保存与显示学生信息。

import java.util.ArrayList;
import java.util.Scanner;import com.sun.org.apache.xpath.internal.Arg;
public class Student {
//两个私有属性
private int no ;
private String name ;
//默认构造函数
public Student(){}
//带参构造函数
public Student(int no,String name){
this.no=no;
this.name=name;
}
//添加学生信息
public void addStudentInfo(ArrayList list){
String flag1="yes";
do{
Student student=new Student();
Scanner in =new Scanner(System.in);
System.out.println("请输入学生学号:");
student.setNo(in.nextInt());
System.out.println("请输入学生姓名:");
student.setName(in.next());
list.add(student);
System.out.println("是否继续添加学生信息(yes/no)?");
flag1=in.next();
} while(flag1.equals("yes"));

}
//读取学生信息
public void showStudentInfo(ArrayList<Student> list){
System.out.println(" 学生no: "+" 学生name: ");
for(Student student:list){
System.out.println(" "+student.getNo()+" "+student.getName());
}
}

public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}

public static void main(String arg[]) {

ArrayList<Student> studentList= new ArrayList<Student>();
Student student= new Student();
Scanner inn= new Scanner(System.in);
while(true){
System.out.println("----------------- 欢迎使用学生管理系统------------------");
System.out.println("1.输入学生信息");
System.out.println("2.显示学生信息");
System.out.println("0.退出系统");
System.out.println("请选择....");
int nn= inn.nextInt();
switch (nn) {
case 1:
student.addStudentInfo(studentList);
break;
case 2:
System.out.println("学生信息如下:");
student.showStudentInfo(studentList);
break;
case 0:
System.exit(0);
System.out.println("系统退出!");
break;
default:
break;
}
}
} }

热点内容
越容易压缩 发布:2025-01-13 07:37:37 浏览:557
ecstore数据库 发布:2025-01-13 07:29:43 浏览:296
手机设置密码忘记了怎么解开 发布:2025-01-13 07:28:29 浏览:20
存储卡交流 发布:2025-01-13 07:16:06 浏览:984
php字符串浮点数 发布:2025-01-13 07:15:28 浏览:998
python排序cmp 发布:2025-01-13 07:09:04 浏览:72
云脚本精灵 发布:2025-01-13 07:03:27 浏览:619
高维访问 发布:2025-01-13 07:03:23 浏览:976
保卫萝卜有脚本吗 发布:2025-01-13 06:30:29 浏览:743
天猫上传 发布:2025-01-13 06:06:35 浏览:156