Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a complete Java program called CalcAvgDropLowest according to the followin

ID: 3814040 • Letter: W

Question

Write a complete Java program called CalcAvgDropLowest according to the following guidelines.

The program prompts the user for five to ten numbers all on one line, separated by spaces, calculates the average of all those numbers except the lowest n numbers, where n is given by the user, and displays all the numbers and the calculated average to the user.

The program uses methods to:

get the numbers used to calculate the average,

get the number of lowest numbers to drop before calculating the average,

calculate the average of the numbers (except the lowest n numbers) entered by the user, and

print the results.

The first method should take no arguments and return an array of doubles.

The second method should take no arguments and return a single integer, the number of the lowest numbers to drop before calculating the average.

The third method should take an array of doubles (the return value of the first method above) and a single integer value (the number of lowest items to drop before calculating the average) and return a double (the average of all the numbers except the lowest n values).

The fourth method should take an array of doubles, an integer, and a double as arguments but have no return value.

For example:

If the user gives these numbers for calculating the average:

40 60 80 100 20

and the user gives the number 2 to indicate how many of the lowest values should be dropped before calculating the average, then

the program should give as output:

Given the numbers 40.00, 60.00, 80.00, 100.00, and 20.00, the average of all the numbers except the lowest 2 numbers is 80.00

-------------top is the requirement-------------

I have some code need help finishing it! based on the requirements!!

the print out should be like the img.

package calcavgdroplowest;

import java.util.Scanner;
import java.util.Arrays;


public class CalcAvgDropLowest {
  
public static void main(String[] args) {
// TODO code application logic here
double[] numbersFromUser = getNumbers();
int numberOfNumbersToDrop = 2;
//int numbersOfNumbersToDrop = getNumbersOfNumbersToDrop();
double average = calculateAverage(numbersFromUser, numberOfNumbersToDrop);
printResults(numbersFromUser, numberOfNumbersToDrop, average);
}
  
public static double[] getNumbers() {
Scanner in = new Scanner(System.in);
System.out.print("Enter 5 to 10 numbers all on one line, separated by spaces: ");
String lineOfNumbers = in.nextLine();
String[] numbers = lineOfNumbers.split("\s+");
double[] arrayOfNumbers = new double[numbers.length];
for (int i = 0; i < numbers.length; i++) {
arrayOfNumbers[i] = Double.parseDouble(numbers[i]);
}
return arrayOfNumbers;
}
  
public static double calculateAverage(double[] numbers, int numberOfItemsToDrop){
  
double average = 0.0;
double[] numbersForSorting = Arrays.copyOf(numbers, numbers.length);
Arrays.sort(numbersForSorting);
  
double sum = 0.0;
}
  
  


}

Enter S to 10 numbers all on one line, separated by spaces 2 1 4 3 S Given the numbers 2.00 1.00 4.00, 3.00, and 5.00 the average of all the numbers except the lowest 2 numbers is 4.00 BUILD SUCCESSFUL (total time 6 seconda)

Explanation / Answer

please find the code

import java.util.Scanner;
import java.util.Arrays;

public class CalcAvgDropLowest {
  
public static void main(String[] args) {
// TODO code application logic here
double[] numbersFromUser = getNumbers();
System.out.println("how many numbers you want to drop");
  
int numberOfNumbersToDrop = numberTodrop();
  
  
//int numbersOfNumbersToDrop = getNumbersOfNumbersToDrop();
double average = calculateAverage(numbersFromUser, numberOfNumbersToDrop);
printResults(numbersFromUser, numberOfNumbersToDrop, average);
}
  
public static int numberTodrop(){
   Scanner sc = new Scanner(System.in);
       int numberTodrop = sc.nextInt();
       return numberTodrop;
}
public static double[] getNumbers() {
Scanner in = new Scanner(System.in);
System.out.print("Enter 5 to 10 numbers all on one line, separated by spaces: ");
String lineOfNumbers = in.nextLine();
String[] numbers = lineOfNumbers.split("\s+");
double[] arrayOfNumbers = new double[numbers.length];
for (int i = 0; i < numbers.length; i++) {
arrayOfNumbers[i] = Double.parseDouble(numbers[i]);
}
return arrayOfNumbers;
}
  
public static double calculateAverage(double[] numbers, int numberOfItemsToDrop){
double average = 0.0;
double[] numbersForSorting = Arrays.copyOf(numbers, numbers.length);
Arrays.sort(numbersForSorting);
double sum = 0.0;
for(int i=numberOfItemsToDrop;i<numbersForSorting.length;i++){
   sum = sum + numbersForSorting[i];
}
return (sum/(numbersForSorting.length-numberOfItemsToDrop));
}
public static void printResults(double numbersFromUser[], int numbertoDrop, double average ){
   System.out.print("Given the numbers ");
   for(int i=0;i<numbersFromUser.length;i++){
       if(i==numbersFromUser.length-1)
           System.out.print(" and "+numbersFromUser[i]);
       else
           System.out.print(numbersFromUser[i]+" ");
   }
   System.out.print(" the average of all the numbers except the lowest "+numbertoDrop+" numbers is "+ average);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote