简单学生管理java代码 简单学生管理java代码是多少
用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;istud.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实现简易学生信息管理系统
使用JFileChooser来选择打开文件, 使用FileInputStream进行读取文件,FileOutputStream来写文件 这些没什么难度吧。中间的显示,你就直接用JFileArea就是了,然后设置为自动换行。
用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]=10gradesArray[i]20) {
b++;
}
else if (gradesArray[i]=20gradesArray[i]30) {
c++;
}
else if (gradesArray[i]=30gradesArray[i]40) {
d++;
}
else if (gradesArray[i]=40gradesArray[i]50) {
e++;
}
else if (gradesArray[i]=50gradesArray[i]60) {
f++;
}
else if (gradesArray[i]=60gradesArray[i]70) {
g++;
}
else if (gradesArray[i]=70gradesArray[i]80) {
h++;
}
else if (gradesArray[i]=80gradesArray[i]90) {
j++;
}
else if (gradesArray[i]=90gradesArray[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的简单学生信息管理系统,这两天急用。求助帮个忙,谢谢。
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
/**
* 学生管理系统:增删查改并按总分排序
*
* @author young
*
*/
//学生类实现Comparable接口是为了实现后面的根据总分进行排序功能。
class Students implements ComparableStudents {
private String sno; // 学号
private String sname; // 姓名
private String ssex; // 性别
private String sgrade; // 班级
private double smath; // 数学成绩
private double seng; // 英语成绩
private double spc; // 计算机成绩
private double sum; // 总分
private double avg; // 平均分
public String getSno() {
return sno;
}
public void setSno(String sno) {
this.sno = sno;
}
public String getSname() {
return sname;
}
public void setSname(String sname) {
this.sname = sname;
}
public String getSsex() {
return ssex;
}
public void setSsex(String ssex) {
this.ssex = ssex;
}
public String getSgrade() {
return sgrade;
}
public void setSgrade(String sgrade) {
this.sgrade = sgrade;
}
public double getSmath() {
return smath;
}
public void setSmath(double smath) {
this.smath = smath;
}
public double getSeng() {
return seng;
}
public void setSeng(double seng) {
this.seng = seng;
}
public double getSpc() {
return spc;
}
public void setSpc(double spc) {
this.spc = spc;
}
public void setSum(double smath, double seng, double spc) {
this.sum = smath + seng + spc;
}
public void setAvg(double smath, double seng, double spc) {
this.avg = Double.valueOf(String.format("%.2f", (smath + seng + spc) / 3));
}
public double getSum() {
return sum;
}
public double getAvg() {
return avg;
}
@Override
/*
* 功能:通过比较对象的属性来对每一个对象进行排序
*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
public int compareTo(Students s) {
// TODO Auto-generated method stub
if (this.sum s.sum) {
return -1;
} else if (this.sum s.sum) {
return 1;
} else {
return 0;
}
}
@Override
public String toString() {
return "学生信息 ----- 学号:" + this.sno + ", 姓名:" + this.sname
+ ", 性别:" + this.ssex + ", 班级:" + this.sgrade + ", 数学成绩:"
+ this.smath + ", 英语成绩:" + this.seng + ", 计算机成绩: " + this.spc
+ ", 总分:" + this.sum + ", 平均分:" + this.avg;
}
}
public class StudentMan {
public static int cd(Scanner sc) {
int i;
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("|---------- 0 退出 ----------|");
System.out.println("-------------------------------");
System.out.print("请输入你的选择:");
i = sc.nextInt();
return i;
}
//排序
public static void sort(ListStudents stuList) {
Collections.sort(stuList);
for(Students stu : stuList){
System.out.println(stu.toString());
}
}
// 添加学生信息
public static ListStudents addRecord(Scanner sc, ListStudents addList) {
Students stu = new Students();
System.out.print("输入学号:");
stu.setSno(sc.next());
System.out.print("输入姓名:");
stu.setSname(sc.next());
System.out.print("输入性别:");
stu.setSsex(sc.next());
System.out.print("输入班级:");
stu.setSgrade(sc.next());
System.out.print("输入数学成绩:");
stu.setSmath(sc.nextDouble());
System.out.print("输入英语成绩:");
stu.setSeng(sc.nextDouble());
System.out.print("输入计算机成绩:");
stu.setSpc(sc.nextDouble());
// 根据输入的三个成绩算出总分和平均分,并赋值到对应的属性中
stu.setSum(stu.getSmath(), stu.getSeng(), stu.getSpc());
stu.setAvg(stu.getSmath(), stu.getSeng(), stu.getSpc());
// 测试添加的对象的各个属性
// System.out.println(stu.toString());
// 把stu对象添加到集合stuList中,并返回集合
addList.add(stu);
return addList;
}
// 修改学生信息
public static void modifyByNumber(Scanner sc, ListStudents stuList) {
String sno = "";
Students stu = null;
if(stuList.size() == 0){
System.out.println("还没有任何学生信息。");
}else{
System.out.println("输入要修改学生的学号:");
sno = sc.next();
for(int i = 0; i stuList.size(); i++){
if(stuList.get(i).getSno().equals(sno)){
System.out.print("输入新的数学成绩:");
stuList.get(i).setSmath(sc.nextDouble());
System.out.print("输入新的英语成绩:");
stuList.get(i).setSeng(sc.nextDouble());
System.out.print("输入新的计算机成绩:");
stuList.get(i).setSpc(sc.nextDouble());
// 根据输入的三个成绩算出总分和平均分,并赋值到对应的属性中
stuList.get(i).setSum(stuList.get(i).getSmath(), stuList.get(i).getSeng(), stuList.get(i).getSpc());
stuList.get(i).setAvg(stuList.get(i).getSmath(), stuList.get(i).getSeng(), stuList.get(i).getSpc());
}
}
}
}
// 删除学生信息
public static void delRecord(Scanner sc, ListStudents stuList) {
if(stuList.size() == 0){
System.out.println("还没有任何学生信息。");
}else {
System.out.print("输入要删除的学号:");
String sno = sc.next();
// 循环遍历集合查找学生并删除
for(int i = 0; i stuList.size(); i++){
if(stuList.get(i).getSno().equals(sno)){
stuList.remove(i);
}
}
}
}
// 按学号查找
public static void queryBySeatNum(Scanner sc, ListStudents stuList) {
if(stuList.size() == 0){
System.out.println("还没有任何学生信息。");
}else {
System.out.print("输入要查找的学号:");
String sno = sc.next();
// 循环遍历集合查找学生
for(int i = 0; i stuList.size(); i++){
if(stuList.get(i).getSno().equals(sno)){
System.out.println(stuList.get(i).toString());
}
}
}
}
public static void main(String[] args) {
ListStudents stuList = new ArrayListStudents();
Scanner sc = new Scanner(System.in);
int i;
i = cd(sc);
while (i != 0) {
switch (i) {
case 1:
stuList = addRecord(sc, stuList);
break;
case 2:
queryBySeatNum(sc, stuList);
break;
case 3:
modifyByNumber(sc, stuList);
break;
case 4:
sort(stuList);
break;
case 5:
delRecord(sc, stuList);
break;
case 0:
System.out.println("Exit!");
System.exit(0);
break;
}
i = cd(sc);
}
}
}
简单的JAVA学生管理系统代码···
lListStudent students = new ArrayListStudent();
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做一个简单的学生管理系统?
用java写的话,可以用List来实现学生管理系统:\x0d\x0a首先,管理系统是针对学生对象的,所以我们先把学生对象就写出来:\x0d\x0apackage bean;\x0d\x0apublic class Student {\x0d\x0a String name;\x0d\x0a String studentId;\x0d\x0a String sex;\x0d\x0a int grade;\x0d\x0a public Student(String name,String studentId,String sex,int grade){\x0d\x0a this.name= name;\x0d\x0a this.studentId= studentId;\x0d\x0a this.sex = sex;\x0d\x0a this.grade = grade; \x0d\x0a }\x0d\x0a public int getGrade(){\x0d\x0a return grade;\x0d\x0a }\x0d\x0a public String getName(){\x0d\x0a return name;\x0d\x0a }\x0d\x0a public String getSex(){\x0d\x0a return sex;\x0d\x0a }\x0d\x0a public void setGrade(int g){\x0d\x0a this.grade = g;\x0d\x0a }\x0d\x0a public String getStudentId(){\x0d\x0a return studentId;\x0d\x0a }\x0d\x0a}\x0d\x0a这里面定义了一些得到当前学生对象数据的一些get方法,和成绩修改的set方法,代码很简单,就不做详细的解答。\x0d\x0a就下来就是我们的正文了。\x0d\x0a虽然我们暂时不用swing来做界面,但是总得要看的过去吧,所以,先做了一个比较简单的界面:\x0d\x0a System.out.println("***************");\x0d\x0a System.out.println("*欢迎来到学生管理系统 *");\x0d\x0a System.out.println("*1:增加学生 *");\x0d\x0a System.out.println("*2:删除学生 *");\x0d\x0a System.out.println("*3:修改成绩 *");\x0d\x0a System.out.println("*4:查询成绩 *");\x0d\x0a System.out.println("***************");\x0d\x0a System.out.println("您想选择的操作是:");\x0d\x0a这里可以看到,我们的是用一个1234来选择项目,说以不得不讲一下Java如何获取到键盘所输入的数据---------Scanner ,要使用这个,首先需要import进来一个包:\x0d\x0a例如这里:\x0d\x0aimport java.util.*;\x0d\x0a之后的两行代码搞定输入:\x0d\x0aScanner sc = new Scanner(System.in);\x0d\x0a int choice = sc.nextInt();\x0d\x0a接下来就是各个功能的实现:\x0d\x0a\x0d\x0apackage test;\x0d\x0aimport java.util.*;\x0d\x0aimport bean.Student;\x0d\x0apublic class Manager {\x0d\x0a static List StudentList = new LinkedList();\x0d\x0a public static void main(String[] agrs){\x0d\x0a select(StudentList); \x0d\x0a }\x0d\x0a private static void select(List StudentList ){\x0d\x0a System.out.println("***************");\x0d\x0a System.out.println("*欢迎来到学生管理系统 *");\x0d\x0a System.out.println("*1:增加学生 *");\x0d\x0a System.out.println("*2:删除学生 *");\x0d\x0a System.out.println("*3:修改成绩 *");\x0d\x0a System.out.println("*4:查询成绩 *");\x0d\x0a System.out.println("***************");\x0d\x0a System.out.println("您想选择的操作是:");\x0d\x0a Scanner sc = new Scanner(System.in);\x0d\x0a int choice = sc.nextInt(); \x0d\x0a switch(choice){\x0d\x0a //增加学生\x0d\x0a case 1:\x0d\x0a System.out.print("请输入学生的姓名:");\x0d\x0a Scanner Sname = new Scanner(System.in);\x0d\x0a String name = Sname.nextLine();\x0d\x0a System.out.print("请输入学生的性别:");\x0d\x0a Scanner Ssex = new Scanner(System.in);\x0d\x0a String sex = Ssex.nextLine();\x0d\x0a System.out.print("请输入学生的学号:");\x0d\x0a Scanner SId = new Scanner(System.in);\x0d\x0a String studentId = SId.nextLine();\x0d\x0a System.out.print("请输入学生的成绩:");\x0d\x0a Scanner Sgrade = new Scanner(System.in);\x0d\x0a int grade = Sgrade.nextInt();\x0d\x0a StudentList.add(new Student(name,studentId,sex,grade));\x0d\x0a System.out.println("添加成功!!!!!");\x0d\x0a select(StudentList);\x0d\x0a break;\x0d\x0a //删除学生成绩\x0d\x0a case 2:\x0d\x0a System.out.print("请告诉我需要删除学生的学号:");\x0d\x0a Scanner Sid = new Scanner(System.in);\x0d\x0a String SstudentId = Sid.nextLine();\x0d\x0a boolean isfindDelete = false;\x0d\x0a for (int i = 0; i
回答于 2022-11-16
网站栏目:简单学生管理java代码 简单学生管理java代码是多少
链接URL:http://myzitong.com/article/doogsog.html