Answer:
import java.util.Scanner;
public class num9 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter three numbers between 0 and 100");
double num1 = in.nextDouble();
double num2 = in.nextDouble();
double num3 = in.nextDouble();
double min = 0;
double sMin = 0;
double tMin = 0;
if(num1<num2 && num1<num3){
min = num1;
sMin = num2;
tMin = num3;
}
else if(num2<num1 && num2<num3){
min = num2;
sMin = num1;
tMin = num3;
}
else if(num3<num2 && num3<num1){
min = num3;
sMin = num1;
tMin = num2;
}
double average = (sMin+tMin)/2;
System.out.printf("The average of the two highest scores is:%.1f \n",average);
}
}
Explanation:
- Using Java programming language. The Scanner class is used to receive the three numbers. The user is prompted to enter a valid number between 0 and 100.
- Using three IF statements the minimum (min), second largerst (sMin) and the largest (tMin) of the three numbers is determined.
- the average of the sMin and tMin is calculated and printed to the console with the printf method to one decimal place.