Java case: Referee scoring

Keywords: Programming

Title:

In the programming competition, there are six judges to score for the contestants, and the score range is 0-100.

The final scoring rules of players are: (maximum score algorithm, minimum score algorithm, average value algorithm)

Remove the highest score and the lowest score,

The average of the other four scores is the final score of the player. (decimal part is not considered)

The printing results are as follows:

The scores of six judges today (20XX XX XX) are 93, 24, 54, 78, 99, 69

Remove the highest score and the lowest score

Final score: 73 points

Code implementation:

/*
        Key point: Maximum Algorithm
    * In the programming competition, there are six judges to score for the contestants, and the score range is 0-100.
        The final scoring rules of players are: (maximum score algorithm, minimum score algorithm, average value algorithm)
        Remove the highest score and the lowest score,
        The average of the other four scores is the final score of the player. (decimal part is not considered)

            The printing results are as follows:
            The scores of six judges today (20XX XX XX) are 93, 24, 54, 78, 99, 69
            Remove the highest score and the lowest score
            Final score: 73 points
    * */
    public static void main(String[] args) {
        //① Prepare data
        //Define the scores of six judges
        int a,b,c,d,e,f;
        //Define two variables: the highest score and the lowest score
        int max,min;
        //Define variable save final score
        int finalTotal;
        //Get current time
        Date d1 = new Date();
        //Get the string of MM DD YY
        String today = (d1.getYear()+1900)+"-"+(d1.getMonth()+1)+"-"+d1.getDate();
        //Define random number tool
        Random r1 = new Random();
        //② Processing data
        //Generate random score
        a = r1.nextInt(101);
        b = r1.nextInt(101);
        c = r1.nextInt(101);
        d = r1.nextInt(101);
        e = r1.nextInt(101);
        f = r1.nextInt(101);
        //Get the highest score
        max = a>b?a:b;
        max = max>c?max:c;
        max = max>d?max:d;
        max = max>e?max:e;
        max = max>f?max:f;

        //Get the lowest score
        min = a<b?a:b;
        min = min<c?min:c;
        min = min<d?min:d;
        min = min<e?min:e;
        min = min<f?min:f;
        //Final score = (total of 6 points - highest - lowest) / 4
        finalTotal = (a+b+c+d+e+f-max-min)/4;

        //③ Show results
        System.out.println("today("+today+")6 The scores of judges are:"
                +a+","+b+","+c+","+d+","+e+","+f);
        System.out.println("Remove the highest score"+max+",Remove a minimum score"+min);
        System.out.println("The final score is:"+finalTotal+"branch");
    }

Posted by juxstapose on Wed, 12 Feb 2020 09:45:22 -0800