package com.cn;

import java.util.*;

public class DiveScoringProgram

{

public static void main(

String[] args)

{

int index = 0;

//double next;

double highest,lowest;

//double input;

double difficulty = 0;

double sum = 0;

double finalScore;

double[] scores = new double[7];

System.out.println("Enter the " + scores.length +

" judges' scores please.");

System.out.println(" ");

Scanner keyboard = new Scanner(System.in);

scores[0] = keyboard.nextDouble( );

sum = sum + scores[0];

highest = scores[0];

lowest = scores[0];

for (index =1; index < scores.length; index++)

{

scores[index] = keyboard.nextDouble( );

if (scores[index] >= 0)

{

//like follows

sum = sum + scores[index];

highest=highest<scores[index]?scores[index]:scores[0];

lowest=lowest>scores[index]?scores[index]:scores[0];

//Notice here

//your if statement is wrong!!!

/*if (scores[index] > highest)

{

scores[index] = highest;

}

if (scores[index] < lowest)

{

scores[index] = lowest;

} */

}

else

{

System.out.println("Error: negative number entered.");

System.out.println(" ");

}

}

System.out.println(" ");

System.out.println("Enter degree of difficulty please.");

difficulty = keyboard.nextDouble( );

System.out.println(" ");

if ((difficulty >= 1.2) && (difficulty <= 3.8))

{

finalScore = ((sum - highest - lowest) * difficulty * 6.0) / 10.0;

System.out.println("Diver's final score is: ");

System.out.println(finalScore);

}

else

{

System.out.println("Error: degree of difficulty must " +

"be between 1.2 and 3.8.");

}

}

}