java学生成绩管理系统代码
时间: 2023-10-16 10:10:26 浏览: 31
以下是一个简单的Java学生成绩管理系统代码,仅供参考:
```java
import java.util.Scanner;
public class StudentManagementSystem {
static String[] studentNames = new String[100];
static int[] studentScores = new int[100];
static int studentCount = 0;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
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. 退出程序");
int choice = scanner.nextInt();
switch (choice) {
case 1:
addStudent(scanner);
break;
case 2:
editStudentScore(scanner);
break;
case 3:
deleteStudent(scanner);
break;
case 4:
viewStudentScores();
break;
case 5:
return;
default:
System.out.println("无效的选择,请重新输入!");
break;
}
}
}
static void addStudent(Scanner scanner) {
System.out.println("请输入学生姓名:");
String name = scanner.next();
System.out.println("请输入学生成绩:");
int score = scanner.nextInt();
studentNames[studentCount] = name;
studentScores[studentCount] = score;
studentCount++;
System.out.println("学生添加成功!");
}
static void editStudentScore(Scanner scanner) {
System.out.println("请输入要修改成绩的学生姓名:");
String name = scanner.next();
for (int i = 0; i < studentCount; i++) {
if (name.equals(studentNames[i])) {
System.out.println("请输入新的成绩:");
int score = scanner.nextInt();
studentScores[i] = score;
System.out.println("成绩修改成功!");
return;
}
}
System.out.println("没有找到该学生!");
}
static void deleteStudent(Scanner scanner) {
System.out.println("请输入要删除的学生姓名:");
String name = scanner.next();
for (int i = 0; i < studentCount; i++) {
if (name.equals(studentNames[i])) {
for (int j = i; j < studentCount - 1; j++) {
studentNames[j] = studentNames[j + 1];
studentScores[j] = studentScores[j + 1];
}
studentCount--;
System.out.println("学生删除成功!");
return;
}
}
System.out.println("没有找到该学生!");
}
static void viewStudentScores() {
System.out.println("学生姓名\t成绩");
for (int i = 0; i < studentCount; i++) {
System.out.println(studentNames[i] + "\t\t" + studentScores[i]);
}
}
}
```
该系统使用静态数组存储学生姓名和成绩,提供了添加学生、修改学生成绩、删除学生和查看学生成绩等功能。可以根据实际需求进行修改和扩展。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)