java 学生评分

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java 学生评分相关的知识,希望对你有一定的参考价值。

/**
 * CS 180 - Lab 04 - Student
 *
 * Grading system for ASTR 102
 *
 * @author spattni <spattni@purdue.edu>
 *
 * @Lab L16
 *
 * @version 1/27/17
 */

public class Student
{
    private String id;
    private String dept;
    private int part;
    private int abs;
    private int exam;

    /**
     * Student class constructor: Creates a new instance of the Student Class, initializes instance variables with
     * the given arguments:
     *
     * @param id - the student's ID
     * @param dept - the student's dept
     * @param abs - the student's abs
     * @param exam - the student's exams grades
     * @param part - the student's participation
     */

    public Student(String id, String dept, int abs, int exam, int part)
    {
        this.id = id;
        this.dept = dept;
        this.abs = abs;
        this.exam = exam;
        this.part = part;
    }

    public int getOverallScore()
    {
        int totalScore = this.part + this.exam;

        if (this.abs == 0)
            totalScore+=2;

        return totalScore;
    }

    /**
     *
     * @param score overall score
     * @return LetterGrade
     */

    public String getLetterGrade(int score)
    {
        String letterGrade = "";

        if(this.abs >= 5)
            letterGrade = "F";
        else if(score >= 95 && this.exam <=100)
            letterGrade = "A+";
        else if(score >= 90 && this.exam <= 94)
            letterGrade = "A";
        else if(score >= 80 && this.exam <=89)
            letterGrade = "B";
        else if(score >= 70 && this.exam <=79)
            letterGrade = "C";
        else if(score >= 60 && this.exam <=69)
            letterGrade = "D";
        else if(score < 60)
            letterGrade = "F";

        return letterGrade;
    }

    public boolean hasPassedCourse(String letterGrade)
    {
        boolean hasPassed = false;
        if (this.dept.equalsIgnoreCase("PH"))
        {
            hasPassed = letterGrade.equals("A+") || letterGrade.equals("A") || letterGrade.equals("B");
        }
        else if (this.dept.equalsIgnoreCase("CS"))
        {
            hasPassed = letterGrade.equals("A+") || letterGrade.equals("A") || letterGrade.equals("B") || letterGrade.equals("C")
                    || letterGrade.equals("D");
        }
        return hasPassed;
    }

    public static void main(String[] args)
    {
        Student s = new Student("102011", "CS", 4, 55, 5);

        int totScore = s.getOverallScore();
        String grade = s.getLetterGrade(totScore);
        boolean result = s.hasPassedCourse(grade);

        System.out.println(s.id);
        System.out.println("Score: " + totScore);
        System.out.println("Grade: " + grade);

        if (result)
            System.out.println("Student " + s.id + " has passed the course");
        else
            System.out.println("Student " + s.id + " has failed the course");
    }
}

以上是关于java 学生评分的主要内容,如果未能解决你的问题,请参考以下文章

学生为学校教研室开发技能大赛评分系统

Java web分级测试评分C级感受

C/C++学生综合测评系统[2023-03-18]

2011全国大学生电子设计大赛的设计报告怎么写?格式是啥?有啥要求?评分标准是啥?

为啥我的 C 程序不适用于评分?

学生为学校教研室开发技能大赛评分系统