java期末考试(OJ)

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int data[] = new int[10];
        String s = sc.nextLine();
        for(int i=0;i m;
    CourseManagementSystem(){
        m = new HashMap();
    }
    public void add(int no, int grade){
        if(m.containsKey(no)){
            System.out.println("the student already exists");
        }else {
            m.put(no, grade);
        }
    }
    public void delete(int no){
        if(m.containsKey(no)){
            m.remove(no);
        }else
            System.out.println("no such student");
    }
    public int query (int no){
            return m.get(no);
    }
    public static void statistic(){
        int a=0,b=0,c=0,d=0,e=0;

        for(Integer i:m.keySet()) {
            int grade = m.get(i);
            if(grade >=90&&grade<=100)
                a++;
            else if(grade>=80&&grade<=89)
                b++;
            else if(grade>=70&&grade<=79)
                c++;
            else if(grade>=60&&grade<=69)
                d++;
            else
                e++;
        }
        System.out.println("[0-59] : "+e);
        System.out.println("[60-69] : "+d);
        System.out.println("[70-79] : "+c);
        System.out.println("[80-89] : "+b);
        System.out.println("[90-100] : "+a);
    }
}

 

你可能感兴趣的:(OJ)