LinkedList<HashMap<String, Integer>> students = new LinkedList<HashMap<String, Integer>>();

来源:互联网 发布:应知故乡事的前一句 编辑:程序博客网 时间:2024/06/01 07:19
package java17work;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Map;
import java.util.Set;

public class Main {
    public static void main(String[] args)
    {
        LinkedList<HashMap<String, Integer>> students = new LinkedList<HashMap<String, Integer>>();
        Scanner scanner = new Scanner(System.in);
        Scores stuscore = new Scores();
        System.out.println("请输入考试次数");
        int examtimes = scanner.nextInt();
        for(int i = 0;i<examtimes;i++)
            {HashMap<String, Integer> studentscore= new HashMap<String, Integer>();
            for(int j =0;j<stuscore.getNames().length-1;j++)
            {
                System.out.println("请输入"+stuscore.getNames()[j]+"的第"+(i+1)+"次成绩");
                int n = scanner.nextInt();
                studentscore.put(stuscore.getNames()[j],n);
            }
        students.add(studentscore);            
    }
        ScoreService mainway=new ScoreService();
        mainway.output(students);
    }
    
}

阅读全文
0 0
原创粉丝点击