Question: (use java) Complete the exercise starting with the file ArrayListInt.java and Numbers.txt data file. The task is to create a class called InClass01 in file

(use java) Complete the exercise starting with the file ArrayListInt.java and Numbers.txt data file. The task is to create a class called InClass01 in file InClass01.java, with a main method that includes the code snippet in the file above, and additional methods which carry out the following tasks:

  • print the list of numbers, with a count
  • compute the average of the numbers
  • compute the maximum and minimum of the numbers,
  • filter out the even numbers (be sure to do this after the above tasks), using the method that is already in the code snippet

(use java) Complete the exercise starting with the file ArrayListInt.java and Numbers.txt

this is for Number.txt

that's for main method

ArrayList numbers = new ArrayList();

Scanner input = new Scanner(new File("Numbers.txt"));

while (input.hasNextInt()) {

int n = input.nextInt();

numbers.add(n);

}

System.out.println(numbers);

//insert additional methods and calls here ...

filterEvens(numbers);

System.out.println(numbers);

// Removes all elements with even values from the given list.

public static void filterEvens(ArrayList list) {

for (int i = list.size() - 1; i >= 0; i--) {

int n = list.get(i);

if (n % 2 == 0) {

list.remove(i);

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!