Question: Can someone help me with a Java program that achieves these terms? 1. Implementing a Java Class to finish the following tasks through its methods.
Can someone help me with a Java program that achieves these terms?
1. 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
a) Generate 500 random integers between 1 and 100 (1 and 100 are inclusive).
b) Calculate the frequency of each unique random integer.
c) 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 an ascending order of random integers.
d) Print out the median of these random integers.
e) Every time when you run your program, it generates the same external file.
Task 2
a) Read random integer and frequency pairs from the output1.txt file
b) Sort these pairs in a descending order of frequencies
c) 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
