JAVA-制作一个简单的学生成绩管理系统
使用JAVA编写一个简易的学习成绩管理系统
包括,导入学生信息,输出学生信息 代码:
package com.shujua.System;
/*
制作一个学生成绩管理系统
创建一个学生类,定义变量存储学生信息,定义方法实现功能
*/
import java.util.Scanner;
//定义学生类,用来保存学生的基本信息
class stud {
String name;
String id;
int math;
int chinese;
int english;
//定义一个函数用来输入学生信息
public void input() {
Scanner sc = new Scanner(System.in);
System.out.println("请输入学生的姓名");
name = sc.next();
System.out.println("请输入学生的学号");
id = sc.next();
System.out.println("请输入学生的数学成绩");
math = sc.nextInt();
System.out.println("请输入学生的语文成绩");
chinese = sc.nextInt();
System.out.println("请输入学生的英语成绩");
english = sc.nextInt();
}
//定义一个函数用来输出学生信息
public void output() {
System.out.println("姓名: " + name);
System.out.println("学号: " + id);
System.out.println("数学: " + math);
System.out.println("语文: " + chinese);
System.out.println("英语: " + english);
}
}
public class Student {
public static void main(String[] args) {
System.out.println("学生成绩管理系统");
Scanner sc = new Scanner(System.in);
int count = 6;
int o = 0;
stud[] st = new stud[count];
st[o] = new stud();
int a = 0;
while (a != 1) {
System.out.println("请选择你需要的功能");
System.out.println("1:输入学生信息");
System.out.println("2:查看学生信息");
System.out.println("按其他数字退出");
int m = sc.nextInt();
switch (m) {
case 1:
o++;
st[o] = new stud();
st[o].input();
break;
case 2:
int b = 1;
while (b != 0) {
System.out.println("请选择你需要的功能");
System.out.println("1:查找某个学生信息");
System.out.println("2:输出所有学生信息");
System.out.println("3:计算所有学生的总成绩");
System.out.println("按其他数字返回");
int i = sc.nextInt();
for (int h = 1; h <= o; h++) {
System.out.println("学生" + h + "的姓名:" + st[h].name);
}
switch (i) {
case 1:
System.out.println("请输入学生编号");
int l = sc.nextInt();
st[l].output();
break;
case 2:
for (int n = 1; n <= o; n++) {
st[n].output();
}
break;
case 3:
for (int n = 1; n <= o; n++) {
System.out.println("第" + n + "个学生" + st[n].name + "的总成绩" + (st[n].chinese + st[n].english + st[n].math));
}
break;
default:
b = 0;
break;
}
}
default:
a = 1;
break;
}
}
}
}
结果展示:
上一篇:
IDEA上Java项目控制台中文乱码
