Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION: 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,

QUESTION:

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 the 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

GIVEN ArrayListInt.java FILE

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); } } }

GIVEN Numbers.txt FILE

98 58 48 70 66 70 98 59 36 92 95 97 54 83 90 68 36 99 96 6 52 50 22 52 15 79 82 76 27 13 48 95 37 83

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Find the decimal representation of -2/7.

Answered: 1 week ago

Question

Technology. Refer to Case

Answered: 1 week ago