Question: In this assignment, you will use Java to analyze social media posts stored in a file. You will create classes and methods to perform various
In this assignment, you will use Java to analyze social media posts stored in a file. You will create classes and methods to perform various tasks, such as finding the topliked post, calculating average likes, filtering posts by user, sorting posts by likes, and removing posts by content.
Instructions
Objective
The objective of this homework is to practice objectoriented programming concepts in Java by implementing a program that analyzes social media posts.
Task
You are required to create a Java program that analyzes social media posts stored in a file. The program should be able to perform the following tasks:
Find the post with the highest number of likes.
Calculate the average number of likes across all posts.
Filter posts made by a specific user.
Sort posts in descending order based on the number of likes.
Remove posts that contain specific content.
Class Creation:
Create a class named SocialMediaPost with the following attributes:
username String: Username of the post author.
content String: Content of the post.
likes int: Number of likes the post received.
Include appropriate getter methods for each attribute.
Analysis Class:
Create another class named SocialMediaAnalysis.
Implement the following static methods within this class:
topLikedPost: Finds the post with the highest number of likes.
averageLikes: Calculates the average number of likes across all posts.
filterPostByUser: Filters posts made by a specific user.
sortPostByLikes: Sorts posts in descending order based on the number of likes.
removePostByContent: Removes posts that contain specific content.
Main Method:
Implement the main method in a separate class named SocialMain.
Within the main method, read social media posts from this file socialmediapost.txt Download socialmediapost.txt using the provided method readSocialMediaPostFromFile.
Call the implemented methods from the SocialMediaAnalysis class to perform the required analysis on the posts.
Print the results of each analysis.
Sample output:
Top Liked Post: Looking forward to the weekend!
Average Like:
Filter post by user:
Jenny : Enjoying a cup of coffee on this rainy day. likes
Jenny : Feeling grateful for all the blessings. likes
Jenny : Reflecting on the year gone bylikes
Before sorting:
Ryan : Just finished my new blog post. likes
Auora : Excited to announce our new product launch! likes
Jenny : Enjoying a cup of coffee on this rainy day. likes
Rayan : Throwback to last summer's vacation. likes
Auora : Working late tonight to meet deadlines. likes
Jenny : Feeling grateful for all the blessings. likes
Rayan : Looking forward to the weekend! likes
Auora : Spending quality time with family and friends. likes
Jenny : Reflecting on the year gone bylikes
After sorting:
Rayan : Looking forward to the weekend! likes
Auora : Spending quality time with family and friends. likes
Rayan : Throwback to last summer's vacation. likes
Auora : Excited to announce our new product launch! likes
Jenny : Feeling grateful for all the blessings. likes
Auora : Working late tonight to meet deadlines. likes
Ryan : Just finished my new blog post. likes
Jenny : Reflecting on the year gone bylikes
Jenny : Enjoying a cup of coffee on this rainy day. likes
After removing the post containing 'Just finished my new blog post.:
Rayan : Looking forward to the weekend! likes
Auora : Spending quality time with family and friends. likes
Rayan : Throwback to last summer's vacation. likes
Auora : Excited to announce our new product launch! likes
Jenny : Feeling grateful for all the blessings. likes
Auora : Working late tonight to meet deadlines. likes
Jenny : Reflecting on the year gone bylikes
Jenny : Enjoying a cup of coffee on this rainy day. likes
Testing:
Test your program with different sets of social media posts to ensure that it correctly performs the specified tasks.
Submission
Submit your Java program files SocialMainjava along with any necessary documentation if required
Additional Notes:
Ensure that your code is welldocumented with appropriate comments.
Use meaningful variable names and adhere to Java naming conventions.
Handle potential exceptions such as file not found or incorrect file format appropriately.
Test your program thoroughly to verify its correctness and robustness.
Good Luck and Happy Coding!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
