如何用Java语言编写学生成绩管理系统
答案:2 悬赏:0 手机版
解决时间 2021-12-28 21:28
- 提问者网友:风月客
- 2021-12-28 15:17
如何用Java语言编写学生成绩管理系统
最佳答案
- 五星知识达人网友:骨子里都是戏
- 2021-12-28 15:51
package student;
import java.util.Scanner;
public class teststudent {
public static void main(String args[]){
System.out.println("************************学生成绩管理系统*********************");
System.out.println("请输入要管理的学生人数:");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
studentMassage stum = new studentMassage(n);
int flag = 1;
while(flag == 1){
System.out.println("1.输入学生信息");
System.out.println("2.通过姓名查找学生信息");
System.out.println("3.显示全部学生信息");
System.out.println("4.退出系统");
int op = sc.nextInt();
switch(op){
case 1:stum.addStudent(n);
new Scanner(System.in).nextLine();
break;
case 2:
System.out.println("输入学生姓名:");
String name = sc.next();
stum.FindStudent(name);
new Scanner(System.in).nextLine();
break;
case 3:
stum.showallStudent();
new Scanner(System.in).nextLine();
break;
case 4:
flag = 0;
System.out.println("已退出系统!");
break;
default:
System.out.println("输入有误!");
new Scanner(System.in).nextLine();
}
}
}
}
class Date{
int year;
int month;
int day;
public String showDate(){
return year + "/"+ month+"/"+day;
}
}
class student{
int id;
String name;
Date date;
float score;
public student(){
id = 0;
name = null;
date = null;
score = 0f;
}
public void showStudent(){
System.out.println( id + " " + name + " "+ " " + date.showDate()+" "+score);
}
}
class studentMassage{
private student[] stu;
private int flag;
public studentMassage(int n){
flag = 0;
if(stu == null){
stu = new student[n];
for(int i =0;i
stu[i] = new student();
}
}
}
public void addStudent(int n){
flag = 1;
Scanner sc = new Scanner(System.in);
System.out.println("请输入"+n+"个学生信息");
for(int i = 0 ;i
stu[i].date = new Date();
System.out.println("请输入第"+(i+1)+"个学生学号:");
stu[i].id = sc.nextInt();
System.out.println("请输入第"+(i+1)+"个学生姓名:");
stu[i].name = sc.next();
System.out.println("请输入第"+(i+1)+"个学生出生年份:");
stu[i].date.year = sc.nextInt();
System.out.println("请输入第"+(i+1)+"个学生出生月份:");
stu[i].date.month = sc.nextInt();
System.out.println("请输入第"+(i+1)+"个学生出生日期:");
stu[i].date.day = sc.nextInt();
//stu[i].date = new Date(year,month,day);
System.out.println("请输入第"+(i+1)+"个学生分数:");
stu[i].score = sc.nextFloat();
}
}
public void FindStudent(String sname){
student find = null;
if(flag != 0){
for(int i = 0;i
if(sname.equals(stu[i].name))
find = stu[i];
}
if(find == null)
System.out.println("查无此人!");
else
find.showStudent();
}else
System.out.println("没有输入学生信息!");
}
public void showallStudent(){
System.out.println("所有学生的信息如下:");
System.out.println("学号 姓名 生日 分数");
for(int i = 0;i
stu[i].showStudent();
}
}
}
import java.util.Scanner;
public class teststudent {
public static void main(String args[]){
System.out.println("************************学生成绩管理系统*********************");
System.out.println("请输入要管理的学生人数:");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
studentMassage stum = new studentMassage(n);
int flag = 1;
while(flag == 1){
System.out.println("1.输入学生信息");
System.out.println("2.通过姓名查找学生信息");
System.out.println("3.显示全部学生信息");
System.out.println("4.退出系统");
int op = sc.nextInt();
switch(op){
case 1:stum.addStudent(n);
new Scanner(System.in).nextLine();
break;
case 2:
System.out.println("输入学生姓名:");
String name = sc.next();
stum.FindStudent(name);
new Scanner(System.in).nextLine();
break;
case 3:
stum.showallStudent();
new Scanner(System.in).nextLine();
break;
case 4:
flag = 0;
System.out.println("已退出系统!");
break;
default:
System.out.println("输入有误!");
new Scanner(System.in).nextLine();
}
}
}
}
class Date{
int year;
int month;
int day;
public String showDate(){
return year + "/"+ month+"/"+day;
}
}
class student{
int id;
String name;
Date date;
float score;
public student(){
id = 0;
name = null;
date = null;
score = 0f;
}
public void showStudent(){
System.out.println( id + " " + name + " "+ " " + date.showDate()+" "+score);
}
}
class studentMassage{
private student[] stu;
private int flag;
public studentMassage(int n){
flag = 0;
if(stu == null){
stu = new student[n];
for(int i =0;i
}
}
}
public void addStudent(int n){
flag = 1;
Scanner sc = new Scanner(System.in);
System.out.println("请输入"+n+"个学生信息");
for(int i = 0 ;i
System.out.println("请输入第"+(i+1)+"个学生学号:");
stu[i].id = sc.nextInt();
System.out.println("请输入第"+(i+1)+"个学生姓名:");
stu[i].name = sc.next();
System.out.println("请输入第"+(i+1)+"个学生出生年份:");
stu[i].date.year = sc.nextInt();
System.out.println("请输入第"+(i+1)+"个学生出生月份:");
stu[i].date.month = sc.nextInt();
System.out.println("请输入第"+(i+1)+"个学生出生日期:");
stu[i].date.day = sc.nextInt();
//stu[i].date = new Date(year,month,day);
System.out.println("请输入第"+(i+1)+"个学生分数:");
stu[i].score = sc.nextFloat();
}
}
public void FindStudent(String sname){
student find = null;
if(flag != 0){
for(int i = 0;i
find = stu[i];
}
if(find == null)
System.out.println("查无此人!");
else
find.showStudent();
}else
System.out.println("没有输入学生信息!");
}
public void showallStudent(){
System.out.println("所有学生的信息如下:");
System.out.println("学号 姓名 生日 分数");
for(int i = 0;i
}
}
}
全部回答
- 1楼网友:逐風
- 2021-12-28 17:16
写过一个类似的给了你吧 package student; import java.util.scanner; public class teststudent { public static void main(string args[]){ system.out.println("************************学生成绩管理系统*********************"); system.out.println("请输入要管理的学生人数:"); scanner sc = new scanner(system.in); int n = sc.nextint(); studentmassage stum = new studentmassage(n); int flag = 1; while(flag == 1){ system.out.println("1.输入学生信息"); system.out.println("2.通过姓名查找学生信息"); system.out.println("3.显示全部学生信息"); system.out.println("4.退出系统"); int op = sc.nextint(); switch(op){ case 1:stum.addstudent(n); new scanner(system.in).nextline(); break; case 2: system.out.println("输入学生姓名:"); string name = sc.next(); stum.findstudent(name); new scanner(system.in).nextline(); break; case 3: stum.showallstudent(); new scanner(system.in).nextline(); break; case 4: flag = 0; system.out.println("已退出系统!"); break; default: system.out.println("输入有误!"); new scanner(system.in).nextline(); } } } } class date{ int year; int month; int day; public string showdate(){ return year + "/"+ month+"/"+day; } } class student{ int id; string name; date date; float score; public student(){ id = 0; name = null; date = null; score = 0f; } public void showstudent(){ system.out.println( id + " " + name + " "+ " " + date.showdate()+" "+score); } } class studentmassage{ private student[] stu; private int flag; public studentmassage(int n){ flag = 0; if(stu == null){ stu = new student[n]; for(int i =0;i<n;++i){ stu[i] = new student(); } } } public void addstudent(int n){ flag = 1; scanner sc = new scanner(system.in); system.out.println("请输入"+n+"个学生信息"); for(int i = 0 ;i<stu.length;++i){ stu[i].date = new date(); system.out.println("请输入第"+(i+1)+"个学生学号:"); stu[i].id = sc.nextint(); system.out.println("请输入第"+(i+1)+"个学生姓名:"); stu[i].name = sc.next(); system.out.println("请输入第"+(i+1)+"个学生出生年份:"); stu[i].date.year = sc.nextint(); system.out.println("请输入第"+(i+1)+"个学生出生月份:"); stu[i].date.month = sc.nextint(); system.out.println("请输入第"+(i+1)+"个学生出生日期:"); stu[i].date.day = sc.nextint(); //stu[i].date = new date(year,month,day); system.out.println("请输入第"+(i+1)+"个学生分数:"); stu[i].score = sc.nextfloat(); } } public void findstudent(string sname){ student find = null; if(flag != 0){ for(int i = 0;i<stu.length;++i){ if(sname.equals(stu[i].name)) find = stu[i]; } if(find == null) system.out.println("查无此人!"); else find.showstudent(); }else system.out.println("没有输入学生信息!"); } public void showallstudent(){ system.out.println("所有学生的信息如下:"); system.out.println("学号 姓名 生日 分数"); for(int i = 0;i<stu.length;++i){ stu[i].showstudent(); } } }
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯