當前位置:首頁 » 編程語言 » 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 03:21:20 瀏覽:88
linuxatop 發布:2025-01-13 03:19:01 瀏覽:438
彩38源碼下載 發布:2025-01-13 03:16:51 瀏覽:971
手機app緩存可不可以刪 發布:2025-01-13 03:10:46 瀏覽:937
安卓怎麼顯示第五個人圖鑒 發布:2025-01-13 03:03:23 瀏覽:922
內網訪問很慢 發布:2025-01-13 03:01:01 瀏覽:454
魔獸腳本p閃 發布:2025-01-13 02:58:40 瀏覽:290
java遞減 發布:2025-01-13 02:54:40 瀏覽:489
決策樹的演算法例題 發布:2025-01-13 02:53:15 瀏覽:448
腳本四要素 發布:2025-01-13 02:40:18 瀏覽:929