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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started