当前位置:首页 » 编程语言 » 学生管理系统的java代码

学生管理系统的java代码

发布时间: 2022-10-24 05:33:20

java学生管理系统

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.lang.*;

public class Students extends Applet implements ActionListener
{
Vector StuInf=new Vector();
StudentInf SI;
String xm;
String bj;
int i,j,xh,cj;
static int mid;
Label prompt1=new Label("学生成绩管理系统");
Label prompt2=new Label(" 用户:");
Label prompt3=new Label(" 密码:");
Label prompt4=new Label(" 班级:");
Label prompt5=new Label(" 成绩:");
TextField input1=new TextField(8);
TextField input2=new TextField(8);
TextField input3=new TextField(8);
TextField input4=new TextField(8);
Button btn1=new Button("登录");
Button btn2=new Button("增加");
Button btn3=new Button("修改");
Button btn4=new Button("删除");

public void init()
{
setLayout(new GridLayout(6,3));
add(new Label());
add(prompt1);
add(new Label());
add(prompt2);
add(input1);
add(new Label());
add(prompt3);
add(input2);
add(btn1);
add(prompt4);
add(input3);
add(new Label());
add(prompt5);
add(input4);
add(new Label());
add(btn2);
add(btn3);
add(btn4);
prompt4.setVisible(false);
prompt5.setVisible(false);
input3.setVisible(false);
input4.setVisible(false);
btn2.setVisible(false);
btn3.setVisible(false);
btn4.setVisible(false);
btn1.addActionListener(this);
btn2.addActionListener(this);
btn3.addActionListener(this);
btn4.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand()=="登录")
{
String a,b;
a=input1.getText();
b=input2.getText();
input1.setText("");
if((a.equals("12")==true)&&(b.equals("12")==true))
{
prompt2.setText(" 姓名:");
prompt3.setText(" 学号:");
prompt4.setVisible(true);
prompt5.setVisible(true);
input3.setVisible(true);
input4.setVisible(true);
btn2.setVisible(true);
btn3.setVisible(true);
btn4.setVisible(true);
btn3.setEnabled(false);
btn4.setEnabled(false);
btn1.setLabel("查询");
input1.setText("登录成功");
input1.selectAll();
}
else
input2.setText("用户名或密码错");
}
if(e.getActionCommand()=="增加")
{
boolean scucss=true;
try
{
XingMing();
}
catch(EmptyException as)
{
input1.setText("姓名不能为空");
scucss=false;
}
try
{
xh=Integer.parseInt(input2.getText());
}
catch(NumberFormatException m)
{
input2.setText("学号为空或格式错");
scucss=false;
}
bj=input3.getText();
try
{
ChengJi();
}
catch(EmptyException as)
{
cj=-1;
}
catch(OverException dd)
{
input4.setText("应在0-100间");
scucss=false;
}
catch(NumberFormatException cm)
{
input4.setText("成绩应为数据");
scucss=false;
}
if(scucss==true)
{
SI=new StudentInf(xm,xh,bj,cj);
Insert(SI);
}
}
if(e.getActionCommand()=="修改")
{
xm=input1.getText();
xh=Integer.parseInt(input2.getText());
bj=input3.getText();
cj=Integer.parseInt(input4.getText());
SI=new StudentInf(xm,xh,bj,cj);
StuInf.setElementAt(SI, mid);
btn3.setEnabled(false);
}
if(e.getActionCommand()=="删除")
{
StuInf.removeElementAt(mid);
btn4.setEnabled(false);
input1.setText("删除成功");
input2.setText("");
input3.setText("");
input4.setText("");
}
if(e.getActionCommand()=="查询")
{
boolean right=true;
try
{
xh=Integer.parseInt(input2.getText());
}
catch(NumberFormatException m)
{
input2.setText("学号为空或格式错");
right=false;
}
if(right==true)
{
search(xh);
btn3.setEnabled(true);
btn4.setEnabled(true);
}
}

}
//查找方法
public void search(int k)
{
boolean exist=false;
int low=0;
int high=StuInf.size()-1;
while(low<=high)
{
mid=(high+low)/2;
StudentInf a1=(StudentInf) StuInf.elementAt(mid);
if(a1.getStuNo()==k)
{
SI=(StudentInf) StuInf.elementAt(mid);
String x = String.valueOf(SI.getStuNo());
exist=true;
input1.setText(SI.getname());
input1.selectAll();
input2.setText("0"+x);
input3.setText(SI.getClassNo());
if(SI.getLevel()==-1)
input4.setText("未参加考试");
else
{
String y = String.valueOf(SI.getLevel());
input4.setText(y);
}
break;
}
else if(a1.getStuNo()<k)
low=mid+1;
else
high=mid-1;
}
if(exist==false)
{
input1.setText("无此学号学生信息");
input1.selectAll();
}
}
//添加方法
public void Insert(StudentInf q)
{
int i=0;

if(StuInf.isEmpty()==true)
{
StuInf.addElement(q);
input1.setText("");
input2.setText("");
input3.setText("");
input4.setText("");
}
else
{
StudentInf xh;
xh=(StudentInf) StuInf.firstElement();
while(xh.getStuNo()<q.getStuNo())
{
i++;
if(i<StuInf.size())
xh=(StudentInf) StuInf.elementAt(i);
else
break;
}
if(xh.getStuNo()==q.getStuNo())
{
input2.setText("此学生信息已存在");
input2.requestFocus();
input2.selectAll();
}
else
{
StuInf.insertElementAt(q,i);
input1.setText("");
input2.setText("");
input3.setText("");
input4.setText("");
}
}
}

//异常类
class OverException extends Exception
{
String over;
}
class EmptyException extends Exception
{
String empty;
}
void XingMing() throws EmptyException
{
if((input1.getText()).equals(""))
throw (new EmptyException());
else
xm=input1.getText();
}
void ChengJi() throws OverException,EmptyException
{
if((input4.getText()).equals(""))
throw(new EmptyException());
else
cj=Integer.parseInt(input4.getText());
if(cj<0||cj>100)
throw (new OverException());
}

//学生信息类
public class StudentInf
{
private String name;
private int StuNo;
private String ClassNo;
private int Level;
StudentInf(String xingming,int xuehao,String banji,int chengji)
{
name=xingming;
StuNo=xuehao;
ClassNo=banji;
Level=chengji;
}
public int getStuNo()
{
return StuNo;
}
public String getname()
{
return name;
}
public String getClassNo()
{
return ClassNo;
}
public int getLevel()
{
return Level;
}
}

}

㈡ 简单的JAVA学生管理系统代码···

lList<Student> students = new ArrayList<Student>();
BufferedReader br = new BufferedReader(new FileReader("D:\student.txt"));
String tmpStr = br.readLine();
while(tmpStr != null){
int firstIndex = tmpStr.indexOf(" ");

int secondIndex = tmpStr.indexOf(" ",firstIndex + 1);

int thirdIndex = tmpStr.indexOf(" ", secondIndex + 1);

int forthIndex = tmpStr.indexOf(" ", thirdIndex + 1);
Integer stuId = Integer.parseInt(tmpStr.substring(0,firstIndex));
String stuName = tmpStr.substring(firstIndex + 1,secondIndex);

Integer stuYW = Integer.parseInt(tmpStr.substring(secondIndex + 1,thirdIndex));
Integer stuSX = Integer.parseInt(tmpStr.substring(thirdIndex + 1,forthIndex));
Integer stuYY = Integer.parseInt(tmpStr.substring(forthIndex + 1));
Student student = new Student();
student.setStuId(stuId);

student.setStuName(stuName);

student.setStuYW(stuYW);

student.setStuSX(stuSX);
student.setStuYY(stuYY);
students.add(student);

tmpStr.readLine();

}
//创建一个学生实体类 封装stuId stuName stuYW stuSx stuYY 这5个属性。。。
//已经帮你把数据拆分出来 并以Student 对象的形式放入集合中了 接下来 给分吧 哇咔咔

㈢ 用java编写学生管理系统

我也是初学写的不好
public class Student {
static int[] gradesArray={87,68,94,100,83,78,85,91,76,87};
public Student(int[]gradesArray){

}
public void printAllGrade(){
for (int i = 0; i < gradesArray.length; i++) {
System.out.println("学号"+(i+1)+"成绩是"+gradesArray[i]);
}
}
public void printAvarage(){
double sum = 0;
for (int i = 0; i < gradesArray.length; i++) {
sum+=gradesArray[i];
}
System.out.println("\n平均成绩是"+sum/gradesArray.length);
}
public void printMax(){
int max=gradesArray[0];
for (int i = 0; i < gradesArray.length; i++) {
if(gradesArray[i]>max){
max=gradesArray[i];
}
}
System.out.println("\n最高分时"+max);
}
public void printMin(){
int min=gradesArray[0];
for (int i = 0; i < gradesArray.length; i++) {
if (gradesArray[i]<min){
min=gradesArray[i];
}
}
System.out.println("\n最低分时"+min);
}
public void printDistribution(){
int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0;
for (int i = 0; i < gradesArray.length; i++) {
if(gradesArray[i]<10){
a++;
}else if (gradesArray[i]>=10&&gradesArray[i]<20) {
b++;
}
else if (gradesArray[i]>=20&&gradesArray[i]<30) {
c++;
}
else if (gradesArray[i]>=30&&gradesArray[i]<40) {
d++;
}
else if (gradesArray[i]>=40&&gradesArray[i]<50) {
e++;
}
else if (gradesArray[i]>=50&&gradesArray[i]<60) {
f++;
}
else if (gradesArray[i]>=60&&gradesArray[i]<70) {
g++;
}
else if (gradesArray[i]>=70&&gradesArray[i]<80) {
h++;
}
else if (gradesArray[i]>=80&&gradesArray[i]<90) {
j++;
}
else if (gradesArray[i]>=90&&gradesArray[i]<100) {
k++;
}
}
System.out.println("\n成绩分布是");
System.out.print("0-10:");
for (int i = 0; i <=a; i++) {
System.out.print("*");
}
System.out.print("10-20:");
for (int i = 0; i <=b; i++) {
System.out.print("*");
}
System.out.print("20-30:");
for (int i = 0; i <=c; i++) {
System.out.print("*");
}
System.out.print("30-40:");
for (int i = 0; i <=d; i++) {
System.out.print("*");
}
System.out.print("40-50:");
for (int i = 0; i <=e; i++) {
System.out.print("*");
}
System.out.print("50-60:");
for (int i = 0; i <=f; i++) {
System.out.print("*");
}
System.out.print("60-70:");
for (int i = 0; i <=g; i++) {
System.out.print("*");
}
System.out.print("70-80:");
for (int i = 0; i <=h; i++) {
System.out.print("*");
}
System.out.print("80-90:");
for (int i = 0; i <=j;i++) {
System.out.print("*");
}
System.out.print("90-100:");
for (int i = 0; i <=k; i++) {
System.out.print("*");
}
}
public static void main(String[] args) {
Student student=new Student(gradesArray);
student.printAllGrade();
student.printAvarage();
student.printMax();
student.printMin();
student.printDistribution();
}

}

㈣ JAVA 学生管理系统 求符合下列要求的代码

抽象层Student类-----然后派生出三个继承类,分别是三种学生,每个学生都有各自的字段,公共字段(学号,姓名)放入抽象父类。
方法很简单。写写就行了。

㈤ 用java编写学生管理系统

package com.tree;

import java.util.Arrays;

public class StudentDemo {

private int[] temp;

public StudentDemo(int[] temp) {
this.temp = temp;
}

public void printAllGrade() {
if (temp != null) {
for (int i = 0; i < temp.length; i++) {
System.out.println("学号 " + (i + 1) + ":" + temp[i]);
}
} else {
System.out.println("参数有误!");
}
}

public void printAvarage() {
if (temp != null) {
Arrays.sort(temp);// 排序数据
double sum=0.00;
for (int i = 0; i < temp.length; i++) {
sum+=temp[i];
}
System.out.println("平均分 :" + sum/temp.length);
System.out.println("最高分 :" + temp[temp.length-1]);
System.err.println("最低分 :" + temp[0]);

} else {
System.out.println("参数有误!");
}

}

public void printDistribution(){
if(temp!=null){
Arrays.sort(temp);// 排序数据
StringBuffer a10 = new StringBuffer();//00-09
StringBuffer a20 = new StringBuffer();//10-19
StringBuffer a30 = new StringBuffer();//20-29
StringBuffer a40 = new StringBuffer();//30-39
StringBuffer a50 = new StringBuffer();//40-49
StringBuffer a60 = new StringBuffer();//50-59
StringBuffer a70 = new StringBuffer();//60-69
StringBuffer a80 = new StringBuffer();//70-79
StringBuffer a90 = new StringBuffer();//80-89
StringBuffer a99 = new StringBuffer();//90-99
StringBuffer a100 = new StringBuffer();//一百分;
for (int i = 0; i < temp.length; i++) {
if (temp[i] < 10) {
a10.append("*");
} else if (temp[i] < 20) {
a20.append("*");
} else if (temp[i] < 30) {
a30.append("*");
} else if (temp[i] < 40) {
a40.append("*");
} else if (temp[i] < 50) {
a50.append("*");
} else if (temp[i] < 60) {
a60.append("*");
} else if (temp[i] < 70) {
a70.append("*");
} else if (temp[i] < 80) {
a80.append("*");
} else if (temp[i] < 90) {
a90.append("*");
} else if(temp[i] <100){
a100.append("*");
}else {
a100.append("*");
}
}
System.out.println("00-09: "+a10);
System.out.println("10-19: "+a20);
System.out.println("20-29: "+a30);
System.out.println("30-39: "+a40);
System.out.println("40-49: "+a50);
System.out.println("50-59: "+a60);
System.out.println("60-69: "+a70);
System.out.println("70-79: "+a80);
System.out.println("80-89: "+a90);
System.out.println("90-99: "+a99);
System.out.println("100:"+a100);
}else{
System.out.println("参数有误!");
}

}

public static void main(String[] args) {
int[] gradesArray = { 87, 68, 94, 100, 83, 78, 85, 91, 76, 87 };
StudentDemo s = new StudentDemo(gradesArray);
s.printAllGrade();
s.printDistribution();
s.printAvarage();

}

}

printMax() 输出学生的最高成绩 和 printMin() 输出学生的最低成绩 我为了方便就直接放到printAvarage()里面了,你自己看下就明白;

这题太简单了,给分吧;

㈥ 求用Java编写的学生成绩管理系统的完整代码

packagejdbcproj;
importjava.sql.*;
importjava.awt.BorderLayout;
importjava.awt.EventQueue;

importjavax.swing.JFrame;
importjavax.swing.JPanel;
importjavax.swing.border.EmptyBorder;
importjavax.swing.JLabel;
importjavax.swing.JOptionPane;
importjavax.swing.JTextField;
importjavax.swing.JButton;
importjava.awt.event.ActionListener;
importjava.sql.Connection;
importjava.sql.PreparedStatement;
importjava.sql.SQLException;
importjava.awt.event.ActionEvent;

{

privateJPanelcontentPane;
privateJTextFieldtxtname;
privateJTextFieldtxtpassword;


/**
*Launchtheapplication.
*/
publicstaticvoidmain(String[]args){
EventQueue.invokeLater(newRunnable(){
publicvoidrun(){
try{
MainFrameframe=newMainFrame();
frame.setVisible(true);
}catch(Exceptione){
e.printStackTrace();
}
}
});
}

/**
*Createtheframe.
*/
publicMainFrame(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100,100,661,399);
contentPane=newJPanel();
contentPane.setBorder(newEmptyBorder(5,5,5,5));
setContentPane(contentPane);
contentPane.setLayout(null);

JLabellblNewLabel=newJLabel("u7528u6237u540D");
lblNewLabel.setBounds(114,51,72,18);
contentPane.add(lblNewLabel);

JLabellblNewLabel_1=newJLabel("u5BC6u7801");
lblNewLabel_1.setBounds(114,106,72,18);
contentPane.add(lblNewLabel_1);

txtname=newJTextField();
txtname.setBounds(261,48,86,24);
contentPane.add(txtname);
txtname.setColumns(10);

txtpassword=newJTextField();
txtpassword.setBounds(261,103,86,24);
contentPane.add(txtpassword);
txtpassword.setColumns(10);

JButtonbtnadd=newJButton("u589Eu52A0");
btnadd.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
if(txtname.getText().equals("")||txtpassword.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用户名和密码不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Usersu=newUsers();
u.setPwd(txtpassword.getText());
u.setUsername(txtname.getText());
UserDAOusdo=newUserDAO();
usdo.addUser(u);
}
}
});
btnadd.setBounds(45,205,113,27);
contentPane.add(btnadd);

JButtonbtndelete=newJButton("u5220u9664");
btndelete.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEventarg0){
if(txtname.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用户名不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
UserDAOusdo=newUserDAO();
usdo.delUser(txtname.getText());;
}
}
});
btndelete.setBounds(172,205,113,27);
contentPane.add(btndelete);

JButtonbtnupdate=newJButton("u4FEEu6539");
btnupdate.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
if(txtname.getText().equals("")||txtpassword.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用户名和密码不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Usersu=newUsers();
u.setPwd(txtpassword.getText());
u.setUsername(txtname.getText());
UserDAOusdo=newUserDAO();
usdo.updateUser(u);;
}
}
});
btnupdate.setBounds(300,205,113,27);
contentPane.add(btnupdate);

JButtonbtnfind=newJButton("u67E5u8BE2");
btnfind.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
if(txtname.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用户名不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Usersu=newUsers();
UserDAOusdo=newUserDAO();
u=usdo.findUser(txtname.getText(),txtpassword.getText());
if(u!=null){
JOptionPane.showMessageDialog(getContentPane(),"该用户存在!","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
JOptionPane.showMessageDialog(getContentPane(),"该用户不存在!","提示信息框",JOptionPane.WARNING_MESSAGE);
}
}
}
});
btnfind.setBounds(427,205,113,27);
contentPane.add(btnfind);
//记得要写这个
setVisible(true);
}

}

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

importjava.util.*;
importjava.io.*;

classStuMgr{

publicstaticclassStudent{

publicintid;
publicStringname;
publicintage;

publicStudent(intid,Stringname,intage){
this.id=id;
this.name=name;
this.age=age;
}

@Override
publicStringtoString(){
returnid+","+name+","+age;
}
}

publicList<Student>stuList=newLinkedList<>();

publicvoidadd(){
Scannersc=newScanner(System.in);
System.out.println("请输入学生学号:");
Stringid=sc.nextLine();
intintId=0;
try{
intId=Integer.parseInt(id);
}catch(NumberFormatExceptionex){
System.out.println("学号输入有误,请输入数字!");
return;
}
if(find(intId)!=null){
System.out.println("该学号已经存在!");
return;
}
System.out.println("请输入学生姓名:");
Stringname=sc.nextLine();
System.out.println("请输入学生年龄:");
Stringage=sc.nextLine();
intintAge=0;
try{
intAge=Integer.parseInt(age);
}catch(NumberFormatExceptionex){
System.out.println("年龄输入有误,请输入数字!");
return;
}
Studentstu=newStudent(intId,name,intAge);
stuList.add(stu);
store();
System.out.println("-----------------------");
System.out.println("学生信息已增加");
System.out.println(stu);
System.out.println("-----------------------");
}

publicvoiddel(){
Scannersc=newScanner(System.in);
System.out.println("请输入学生学号:");
Stringid=sc.nextLine();
intintId=0;
try{
intId=Integer.parseInt(id);
}catch(NumberFormatExceptionex){
System.out.println("学号输入有误,请输入数字!");
return;
}
Studentstu=find(intId);
if(stu==null){
System.out.println("该学号不存在!");
return;
}
stuList.remove(stu);
store();
System.out.println("-----------------------");
System.out.println("学生信息已删除");
System.out.println(stu);
System.out.println("-----------------------");
}

publicvoidfind(){
Scannersc=newScanner(System.in);
System.out.println("请输入学生学号:");
Stringid=sc.nextLine();
intintId=0;
try{
intId=Integer.parseInt(id);
}catch(NumberFormatExceptionex){
System.out.println("学号输入有误,请输入数字!");
return;
}
Studentstu=find(intId);
if(stu==null){
System.out.println("该学号不存在!");
return;
}
System.out.println("-----------------------");
System.out.println("查找学生信息如下");
System.out.println(stu);
System.out.println("-----------------------");
}

publicStudentfind(intid){
for(Studentstu:stuList){
if(stu.id==id){
returnstu;
}
}
returnnull;
}

publicvoidmodify(){
store();
}

publicvoidforeach(){
System.out.println("-----------------------");
for(Studentstu:stuList){
System.out.println(stu);
}
System.out.println("-----------------------");
}

publicvoidstore(){
Iteratoriterator=stuList.iterator();
Filefile=newFile("stuList.txt");
FileWriterfw=null;
BufferedWriterwriter=null;
try{
fw=newFileWriter(file);
writer=newBufferedWriter(fw);
while(iterator.hasNext()){
writer.write(iterator.next().toString());
writer.newLine();//换行
}
writer.flush();
}catch(FileNotFoundExceptione){
e.printStackTrace();
}catch(IOExceptione){
e.printStackTrace();
}finally{
try{
writer.close();
fw.close();
}catch(IOExceptione){
e.printStackTrace();
}
}
}

publicstaticvoidmain(String[]args){
StuMgrmgr=newStuMgr();
while(true){
System.out.println("请选择您要进行的操作:");
System.out.println("1:增加学生信息");
System.out.println("2:删除学生信息");
System.out.println("3:查找学生信息");
System.out.println("4:修改学生信息");
System.out.println("5:遍历学生信息");
System.out.println("6:退出");
System.out.println("-----------------------");
Scannersc=newScanner(System.in);
Stringop=sc.nextLine();
if("6".equals(op)){
return;
}
if("1".equals(op)){
mgr.add();
}
if("2".equals(op)){
mgr.del();
}
if("3".equals(op)){
mgr.find();
}
if("4".equals(op)){
mgr.modify();
}
if("5".equals(op)){
mgr.foreach();
}
}

}
}

时间仓促,还有一个modify方法没实现,留给你自己练手。

㈧ 求java学生管理系统源代码 急!!!

完成了,希望能帮到你
刚开始会叫你输入编号选择功能
import java.io.*;

public class student {

public static void main(String args[]) throws IOException{

int[] stud = {77,99,55,46,82,75,65,31,74,85};

System.out.println("请选择功能:");//输入编号选择功能
System.out.println("1、输入学号,查询该学生成绩:");
System.out.println("2、输入成绩,查询学生学号:");
System.out.println("3、输入学号,删除该学生成绩");
System.out.println("请选择编号:");

BufferedReader td = new BufferedReader(new InputStreamReader(System.in));

String temp = td.readLine();

int choice = Integer.valueOf(temp);

if(choice == 1){//一为查询学生成绩

System.out.println("请输入学号:");

BufferedReader sd = new BufferedReader(new InputStreamReader(System.in));

String temp_sd = sd.readLine();

int No = Integer.valueOf(temp_sd);

System.out.print("学号为 "+No+" 的学生成绩为: " + stud[No-1] +"分");
}

if(choice == 2){//二为查询学生编号

System.out.println("请输入成绩:");

BufferedReader sd = new BufferedReader(new InputStreamReader(System.in));

String chengji = sd.readLine();

int temp_cj = Integer.valueOf(chengji);

for(int i=0;i<stud.length;i++){

if(temp_cj == stud[i]){

System.out.print("成绩为 "+ temp_cj+ "的学生的学号为: "+(i+1));

}
}
}
if(choice == 3){//三为删除操作

System.out.println("请输入学号:");

BufferedReader sd = new BufferedReader(new InputStreamReader(System.in));

String temp_sd = sd.readLine();

int No = Integer.valueOf(temp_sd);

stud[No-1]=0;//直接赋值为0,不删除学生

System.out.print("学号为 "+No+" 的学生成绩为: " + stud[No-1] +"分");
}

}
}

㈨ 需要完整代码,谢谢大家!需要Java的学生管理系统,具体的在下面的说明问题,有需要要求。按着要求来就行

public class Course {

private String name;
private float score;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public float getScore() {
return score;
}

public void setScore(float score) {
this.score = score;
}

public Course(String name, float score) {
this.name = name;
this.score = score;
}

public String toString() {
return this.name + ":" + this.score;
}
}

public class Student {

private long id;
private String name;
private int age;
private boolean sex;

public String toString() {

String sex = "女";
if (this.sex == true) {
sex = "男";
}
return String.format("姓名:%s,性别:%s,联系电话:%s,课程信息:%s,课程信息:%s", this.name, sex, this.phone, this.subject.toString());
}

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public boolean isSex() {
return sex;
}

public void setSex(boolean sex) {
this.sex = sex;
}

public String getPhone() {
return phone;
}

public void setPhone(String phone) {
this.phone = phone;
}

public Course[] getSubject() {
return subject;
}

public void setSubject(Course[] subject) {
this.subject = subject;
}

private String phone;
private Course[] subject;

public Student(long i, String n, int a, boolean s, String p) {
this.id = i;
this.name = n;
this.age = a;
this.sex = s;
this.phone = p;
}

}

import java.util.ArrayList;

public class Cmanage {

private ArrayList<Student> students;

//插入
public void addStudent(Student student) {
students.add(student);
}

//删除
public void delStudent(Student student) {
students.remove(student);
}

//查询
public void queryStudent() {
System.out.printf("一共有%d个学生", students.size());
for (Student student : students) {
System.out.println(student.toString());
}
}

//修改
public void updateStudent(long i, String n, int a, boolean s, String p)
{
//以姓名做为唯一标识
for(int j=0;j<students.size();j++)
{
if (students.get(j).getName().equals(n))
{
students.get(j).setId(i);
students.get(j).setAge(a);
students.get(j).setSex(s);
students.get(j).setPhone(p);
}
}
}
}

热点内容
c语言计算ab的值 发布:2025-01-01 07:38:52 浏览:627
如何配置好健康保障 发布:2025-01-01 07:38:52 浏览:860
0基础怎样快速学习编程 发布:2025-01-01 07:34:35 浏览:716
安卓的动态效果在哪里 发布:2025-01-01 07:32:49 浏览:112
win10ftp下载 发布:2025-01-01 07:30:31 浏览:812
江西南昌电信ip服务器云服务器 发布:2025-01-01 07:22:44 浏览:995
图形学算法书 发布:2025-01-01 07:20:41 浏览:560
ftp不安全的服务器 发布:2025-01-01 07:19:34 浏览:554
pdf加密了不能复制 发布:2025-01-01 07:12:05 浏览:499
魔兽插件配置码怎么用 发布:2025-01-01 07:11:25 浏览:791