Complete the following program in C programming language: This program prompts t
ID: 3746457 • Letter: C
Question
Complete the following program in C programming language:This program prompts the user for four exam scores (integers) and then computes and prints the average (double) of three remaining scores after the lowest one is dropped. If the lowest score occurs multiple times, only one occurrence will be dropped.
Examples of a correct output:
Entering 63 58 71 93 gives an average score of 75.66667
Entering 52 84 52 89 gives an average score of 78.333333
This program should only use variables, assignments, selection, and iteration. Nothing more advanced. Complete the following program in C programming language:
This program prompts the user for four exam scores (integers) and then computes and prints the average (double) of three remaining scores after the lowest one is dropped. If the lowest score occurs multiple times, only one occurrence will be dropped.
Examples of a correct output:
Entering 63 58 71 93 gives an average score of 75.66667
Entering 52 84 52 89 gives an average score of 78.333333
This program should only use variables, assignments, selection, and iteration. Nothing more advanced.
This program prompts the user for four exam scores (integers) and then computes and prints the average (double) of three remaining scores after the lowest one is dropped. If the lowest score occurs multiple times, only one occurrence will be dropped.
Examples of a correct output:
Entering 63 58 71 93 gives an average score of 75.66667
Entering 52 84 52 89 gives an average score of 78.333333
This program should only use variables, assignments, selection, and iteration. Nothing more advanced.
Explanation / Answer
import java.util.Scanner;
public class AverageAfterDroppingLowest {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n1 = in.nextInt(), n2 = in.nextInt(), n3 = in.nextInt(), n4 = in.nextInt();
int min = n1;
if(n2 < min) min = n2;
if(n3 < min) min = n3;
if(n4 < min) min = n4;
System.out.println((n1+n2+n3+n4-min)/3.0);
}
}