学生成绩管理系统

/**
 * 作者:
 * 日期:2013-11-20
 * 功能:实现 简单学生成绩管理系统
 * 1.定义一个书租用,用户输入10个同学的成绩,数组下标即代表学生学号
 * 2.输入学号,打印学生成绩
 * 3.输入成绩,打印学号
 * 4.统计各个阶段学生人数(优良中差)
 * 5.输入学号,实现删除学生成绩功能
 */
package com.se;

import java.util.*;

public class Demo1 {
	
	public static void main(String[] args) {
		
		ManageStu ms = null;
		Scanner in = new Scanner(System.in);
		
		while(true){
			
			System.out.println("1.录入成绩");
			System.out.println("2.输入学号,打印学生成绩");
			System.out.println("3.输入成绩,打印学号");
			System.out.println("4.统计各个阶段学生人数");
			System.out.println("5.输入学号,实现删除学生成绩功能");
			System.out.println("6.退出");
			
			int n = in.nextInt();
			if(n==1){
				ms = new ManageStu();
			}else if(n==2){
				
				System.out.println("请输入要查询的学号:");
				int no = in.nextInt();
				ms.getScore(no);
			}else if(n==3){
				
				System.out.println("请输入要查询的成绩:");
				float scor = in.nextFloat();
				ms.getNo(scor);
			}else if(n==4){
				ms.getDifferent();
			}else if(n==5){
				System.out.println("请输入要删除的学号:");
				int no = in.nextInt();
				ms.delStu(no);
			}else if(n==6){
				System.exit(0);
			}
		}
	}
}

//操作学生的类
class ManageStu{
	
	Scanner in = new Scanner(System.in);
	//1.定义一个书租用,用户输入10个同学的成绩,数组下标即代表学生学号
	float score[] = null;
	int num = 5;
	
	public ManageStu(){
		
		score = new float[num];
		
		for(int i=0;i<num;i++){
			
			System.out.println("请输入第"+(i+1)+"位学生成绩");
			score[i] = in.nextFloat();
		}
	}
	
	
	//2.输入学号,打印学生成绩
	public void getScore(int no){
		
		try {
			System.out.println(score[no]);
		} catch (Exception e) {
			System.out.println("输入的学号有误!");
		}
	}
	
	//3.输入成绩,打印学号
	public void getNo(float scor){
		
		int k = 0;
		
		for(int i=0;i<num;i++){
			
			if(score[i] == scor){
				System.out.println("学号:"+i);
				k++;
			}
		}
		
		if(k==0){
			System.out.println("该成绩没有对应的学生!");
		}
	}
	
	//4.统计各个阶段学生人数(优良中差)
	public void getDifferent(){
		
		int a = 0;
		int b = 0;
		int c = 0;
		int d = 0;
		
		for(int i=0;i<num;i++){
			
			if(score[i]<60&&score[i]>0) d++;
			else if(score[i]>=60&&score[i]<80) c++;
			else if(score[i]>=80&&score[i]<90) b++;
			else if(score[i]>=90&&score[i]<=100) a++;
		}
		
		System.out.println("优:"+a+"  良:"+b+"  中:"+c+"  差"+d);
	}
	
	//5.输入学号,实现删除学生成绩功能
	public void delStu(int no){
		
		try {
			score[no] = 0;
			System.out.println("删除成功!");
		} catch (Exception e) {
			System.out.println("输入的学号不存在,删除失败!");
		}
	}
}


  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蟹道人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值