Question: Implementing a Java Class to finish the following tasks through its methods. Implement task1 and task2 in two different methods. Then invoke them in the
Implementing a Java Class to finish the following tasks through its methods. Implement task1 and task2 in two different methods. Then invoke them in the main method.
Task 1
- Generate 200 random integers between 2 and 40 (2 and 40 are inclusive).
- Calculate the frequency of each unique random integer.
- Write random integers and frequencies to an external file named output1.txt line by line. Each line is a random integer and its frequency pair. These pairs are sorted in ascending order of random integers.
- Print out the median of these random integers.
- Every time when you run your program, it generates the same external file.
Task 2
- Read random integer and frequency pairs from the output1.txt file
- Sort these pairs in descending order of frequencies
- Write these newly sorted pairs to an external file named output2.txt line by line.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
