资源简介
实现功能:
1. 输入学生信息
2. 处理学生成绩
3. 处理课程信息
4. 查找信息
代码片段和文件信息
//第二、三次上机的学生系统练习都是这个
import java.util.Scanner;
//面向对象
public class StudentsSystem {
public static int studentAmount;
public static Student[] student;
private static Scanner in;
public static void main(String[] args) {
menu();
}
public static void menu() {
in = new Scanner(System.in);
for(int i=0;i<80;i++){
System.out.print(“*“);
}
System.out.println();
System.out.println(“ *欢迎使用学生信息管理系统* “);
System.out.println(“\t\t 1 输入学生信息“);
System.out.println(“\t\t 2 输出所有同学的平均分“);
System.out.println(“\t\t 3 查找课程分数情况“);
System.out.println(“\t\t 4 排序“);
System.out.println(“\t\t 5 查找学生分数情况(根据姓名)“);
System.out.println(“\t\t 6 查找学生分数情况(根据学号)“);
System.out.println(“\t\t 0 退出“);
System.out.println(“请输入您要执行的操作:“);
int choice = in.nextInt();
switch(choice) {
case 1:{
action1();
break;
}
case 2:{
action2();
break;
}
case 3:{
action3();
break;
}
case 4:{
action4();
break;
}
case 5:{
action5();
break;
}
case 6:{
action6();
break;
}
case 0:{
System.out.println(“欢迎再次使用学生管理系统!“);
System.exit(0);
break;
}
}
}
//输入学生信息
public static void action1() {
in = new Scanner(System.in);
for(int i=0;i<80;i++){
System.out.print(“*“);
}
System.out.println();
System.out.print(“请输入学生人数:“);
int num = in.nextInt();
studentAmount = num;
student = new Student[studentAmount];
for (int i=0; i < studentAmount; i++) {
student[i] = new Student();
System.out.println(“第“ + (i+1) + “个学生“);
System.out.print(“姓名:“);
student[i].Name = in.next();
System.out.print(“学号:“);
student[i].Number = in.nextInt();
System.out.print(“性别:“);
student[i].Sex = in.next();
System.out.print(“java:“);
student[i].java = in.nextInt();
System.out.print(“高数:“);
student[i].math = in.nextInt();
System.out.print(“英语:“);
student[i].english = in.nextInt();
student[i].add = student[i].java + student[i].math + student[i].english;
}
System.out.println(“***********返回主菜单*************“);
menu();
}
//输出所有同学的平均分
public static void action2() {
for(int i = 0; i < studentAmount; i++) {
student[i].ave = student[i].add / 3;
}
for (int j = 0; j < 80; j++){
System.out.print(‘*‘);
}
System.out.println();
System.out.println(“姓名“ + “\t“ + “学号“ + “\t“ + “平均分“);
for(int i = 0; i < studentAmount; i++) {
System.out.println(student[i].Name + “\t“ + student[i].Number + “\t“ + student[i].ave);
}
for (int j = 0; j < 80; j++){
System.out.print(‘*‘);
}
System.out.println(“***********返回主菜单*************“);
menu();
}
//查找课程分数情况
public static void action3() {
final String english_cour = “英语“;
final String math_cour = “高数“;
final String java_cour = “Java“;
int J = 0;
int
评论
共有 条评论