Sign in $ create-account
~/problems ~/discussion ~/contests ~/submission
← ~/submission
run #1461 Compile Error P1001 · 谁拿了最多奖学金
Time 0 ms Memory 0 K Lang Java
// Judge Result
Compile Error. /tmp/voj-1461/RUPWOYmzoPIZ.java:45: error: class Student is public, should be declared in a file named Student.java public class Student { ^ 1 error Compile Error, Time = 0 ms, Memory = 0 KB, Score = 0.
// Source
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        System.out.println("请输入学生人数");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();

        Student[] students = new Student[num];

        Scanner scanner1 = new Scanner(System.in);
        int max = 0;
        int index = 0;
        int sum = 0;
        for (int i = 0; i < students.length; i++)
        {
            String info = scanner1.nextLine();//YaoLin 87 82 Y N 0
            String[] arrs = info.split(" ");
            students[i] = new Student();
            students[i].setName(arrs[0]);
            students[i].setAvgScore(Integer.parseInt(arrs[1]));
            students[i].setClassScore(Integer.parseInt(arrs[2]));
            students[i].setLeader(arrs[3].equals("Y"));
            students[i].setWest(arrs[4].equals("Y"));
            students[i].setPapernum(Integer.parseInt(arrs[5]));

            students[i].calculateMoney();
            sum += students[i].getValue();

            if(max < students[i].getValue())
            {
                max = students[i].getValue();
                index = i;
            }
        }
        System.out.println(students[index].getName());
        System.out.println(students[index].getValue());
        System.out.println(sum);

    }
}

public class Student {
    private String name;
    private int avgScore;
    private int classScore;
    private boolean isLeader;
    private boolean isWest;
    private int papernum;

    private int value;

    public void calculateMoney()
    {
        if(avgScore > 80 && papernum >= 1)
        {
            value += 8000;
        }
        if(avgScore > 85 && classScore > 80)
        {
            value += 4000;
        }
        if(avgScore > 90)
        {
            value += 2000;
        }
        if(avgScore > 85 && isWest)
        {
            value += 1000;
        }
        if(isLeader && classScore > 80)
        {
            value += 850;
        }
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAvgScore() {
        return avgScore;
    }

    public void setAvgScore(int avgScore) {
        this.avgScore = avgScore;
    }

    public int getClassScore() {
        return classScore;
    }

    public void setClassScore(int classScore) {
        this.classScore = classScore;
    }

    public boolean isLeader() {
        return isLeader;
    }

    public void setLeader(boolean leader) {
        isLeader = leader;
    }

    public boolean isWest() {
        return isWest;
    }

    public void setWest(boolean west) {
        isWest = west;
    }

    public int getPapernum() {
        return papernum;
    }

    public void setPapernum(int papernum) {
        this.papernum = papernum;
    }
}
length 3042 B
Compile Error
Judge Result
Run ID#1461
ProblemP1001
Submitted byiwiiwi
LanguageJava
Used Time0 ms
Used Memory0 K
Code length3042 B
Submit TimeFebruary 4, 2020, 2:38:11 PM
Execute TimeFebruary 4, 2020, 2:38:03 PM
// Judger
Java
View Problem