Question: Java Program SAMPLE CODE: Main.Java: // // Add any import statement your program might need class Main { public static void main(String[] args) { //
Java Program

![program might need class Main { public static void main(String[] args) {](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f016348dc22_35566f01633f3020.jpg)
SAMPLE CODE:
Main.Java:
// // Add any import statement your program might need class Main { public static void main(String[] args) { // Implement the main method according the the progam specification } // // Add any methods, specific to the Main class // based on the problem set specification. // } // end of Main classTweet.java:
// // Implement the tweet class according to the problem_set specifications. // class Tweet { // Define the Attributes // Define a constructor. // Override the toString method. } // End of Tweet classTweetLoader.Java
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; // // import any additional packages your program might need. class TweetLoader { // Implement the methods associated with the TweetLoader class // as described in the problem_set specification. } // end of TweetLoader class. Tweet Data.csv:
| Pos | 1459 | @Blackberry & @Facebook U R really about to make me throw this @Blackberry in the trash an get an @Apple iPhone! @Facebook upload issues! |
| Neg | 2228 | Pissed with whoever designs keyboards with @apple for not having a home and end key. working on the CLI i use those keys often |
| Pos | 1400 | My iPhone 4S battery lasted longer than a day. That hasn't happened since my edge iPhone. Nice job @apple. |
| Neg | 1818 | 9% now on my second full charge of the day. Pissed @Apple |
| Neg | 1652 | Correction: @ Best Buy kudos to Chris @ Alamo Ranch S.A. TX-fixed issues couldn't resolve after 1/2 day w/ @ATT & @Apple. Hero of my day! |
| Pos | 1283 | RT @MN2NOVA: Love ios5 Easter eggs. Pull down from middle top to bottom and see what pulls down. Awesome little feature! #ios5 @apple |
| Pos | 1270 | Been off twitter for a few days as I smashed my iPhone but @apple were very nice and gave me a new one :) |
| Pos | 1095 | We're one of a few Featured Education Apps on the @Apple **Website** today sweet! http://t.co/0yWvbe1Z |
| Neg | 1952 | RT @CBM: Lies @apple. the battery on this new iPhone4S is definitely not any better. |
| Neg | 2427 | @apple thanks apple for ios 5 and losing all my contacts! |
| Neg | 1612 | removing all @apple shit. |
| Neg | 2457 | Also @EricGreenspan don't forget @Apple stop closing the app store after each bloody purchase... |
| Pos | 1145 | Save me from #HP's unwanted OS! Help me buy an #iPhone! I have seen the light! #lol http://t.co/8gUP9Acz #backchannel @apple |
| Pos | 1015 | I just realized that the reason I got into twitter was ios5 thanks @apple |
| Neg | 2141 | @apple why don't you guys test your upgrades before you put them out. 15 1/2 hrs u guys wasted of my time yesterday. Thanks. |
| Neg | 1644 | Total chaos at @apple store regent street. Like an Ethiopian feeding station. Can't believe this is same co. that makes all that cool shit. |
| Neg | 1661 | @APPLE Wow @MOTOROLA Just crushed your dreams.... |
| Neg | 1559 | @paulens It surprises me that @Apple throws up an error alert about authorizing and there's no Authorize this computer button. |
| Neg | 2386 | @hbogo @apple - why don't you play nice and let me use HDMI from iPad? Pretty lame. |
| Pos | 1063 | Thank you @apple for Find My Mac - just located and wiped my stolen Air. #smallvictory #thievingbastards |
| Pos | 1008 | Hilarious @youtube video - guy does a duet with @apple 's Siri. Pretty much sums up the love affair! http://t.co/8ExbnQjY |
| Pos | 1012 | @RIM you made it too easy for me to switch to @Apple iPhone. See ya! |
| Pos | 1394 | Impressive service @apple genius bar metro centre. Power cable replaced free n booked in for screen replacement for free :- D |
| Pos | 1252 | Sorry @BlackBerry I'm moving to @Apple. |
| Neg | 2366 | By far the worst experience upgrading out of any version of iOS @apple #iOS5 |
| Neg | 2304 | If @apple doesn't fix iOS5 this week I'm buying a droid #emptythreats |
As part of this problem set, you need to create a simple java program that load a list of data records (stored in a csv file) in two separate data structure, an Array and an ArrayList. So, each data structure should store a copy of the entire data set. Each data entry must be stored as a java object, and the collection of objects will be stored in the Array (or respectively ArrayList) data structure. Moreover, your program should provide methods to display the entries for either data structure. Program Specification: Dataset description: you are provided with a data files, called tweet_data.csv which includes a list of tweets. Each line corresponds to a tweet record. Each tweet record has a unique id, a sentiment category (positive or negative), and the text of the tweet. A sample record in the file might look as follows Pos, 1400, My iPhone 4S battery lasted longer than a day. Implement a Tweet class: you must create a class (Java) that stores information of a single Tweet. The object should be able to store all data associated with the Tweet based in the dataset description. It should also provide a constructor method to instantiate the Tweet object. The constructor method must accept as input all data fields associated with the tweet. For the purposes of this problem set, you must be declared class attributes as public. Finally, the class should override the 'toString method to returning a textual output of the tweet in the following format: o (): For example: 1152 (Pos): I love this course; @CUS1126 exposes me to so many interesting materials Implement a TweetLoader class. Implement a class with the name TweetLoader that will provide the implementation to the following static methods: o public static ArrayList loadAsArrayList(String filename) o public static Tweet[] loadAsArray (String filename) Both methods take as input a filename representing the dataset. The method must read all entries in the file, create a new instance of the Tweet object for every entry in the file and store in data structure. The 'loadAsArrayList' method should store all Tweet obiect as an Both methods take as input a filename representing the dataset. The method must read all entries in the file, create a new instance of the Tweet object for every entry in the file and store in data structure. The 'loadAsArrayList' method should store all Tweet object as an ArrayList and returns the populated object. Similarly, the 'loadAsArray' method should store all Tweet object in an array (i.e. Tweet[]) and return it as its output. When implementing the loadAsArray method, you can assume that you do not know in advance the number of records in the file, so you must make sure you increase the size of the array as needed (i.e. double the size of the array if you reach its limit). Implement a Main class: you must create a Main class that demonstrates the functionality of the TweetLoader methods. Your 'main' method of the Main class should use the "loadAsArrayList' method to load the list of tweets stored from 'tweet_data.csv' in an ArrayList object. Moreover, it should use the LoadAsArray method to load the list of tweets stored from 'tweet_data.csv' in an Array. It should then invoke the displayHead and displayTail' methods to list to first n and last n entries respectively in each data structure. The Main class should also implement the following methods to print the content in the list: o public static void printHead(ArrayList list, int n) Display a list of the first n entries in the input ArrayList. o public static void printHead(Tweet[] list) Display a list of the first n entries in the input Array. o public static void printTail (ArrayList list) Display a list of the last n entries in the input ArrayList. o public static void printTail (Tweet[] list) Program Requirement Your implementation for the above program should comply with the following requirements and specifications: Your program should implement all the specification outlined above. Your code must be well organized, code must be indented. You must use the data file provided as input to your program. Source code files must be submitted (not the compiled files) You must use the template code provided. Your program must compile and run without errors and generate the expected output. Deliverables: You must submit your implementation of the Tweet.java, TweetLoader.java, the Main.java, an output screen showing your code executing and complete the Submission Cover Page for this assignment as listed on the LMS. As part of this problem set, you need to create a simple java program that load a list of data records (stored in a csv file) in two separate data structure, an Array and an ArrayList. So, each data structure should store a copy of the entire data set. Each data entry must be stored as a java object, and the collection of objects will be stored in the Array (or respectively ArrayList) data structure. Moreover, your program should provide methods to display the entries for either data structure. Program Specification: Dataset description: you are provided with a data files, called tweet_data.csv which includes a list of tweets. Each line corresponds to a tweet record. Each tweet record has a unique id, a sentiment category (positive or negative), and the text of the tweet. A sample record in the file might look as follows Pos, 1400, My iPhone 4S battery lasted longer than a day. Implement a Tweet class: you must create a class (Java) that stores information of a single Tweet. The object should be able to store all data associated with the Tweet based in the dataset description. It should also provide a constructor method to instantiate the Tweet object. The constructor method must accept as input all data fields associated with the tweet. For the purposes of this problem set, you must be declared class attributes as public. Finally, the class should override the 'toString method to returning a textual output of the tweet in the following format: o (): For example: 1152 (Pos): I love this course; @CUS1126 exposes me to so many interesting materials Implement a TweetLoader class. Implement a class with the name TweetLoader that will provide the implementation to the following static methods: o public static ArrayList loadAsArrayList(String filename) o public static Tweet[] loadAsArray (String filename) Both methods take as input a filename representing the dataset. The method must read all entries in the file, create a new instance of the Tweet object for every entry in the file and store in data structure. The 'loadAsArrayList' method should store all Tweet obiect as an Both methods take as input a filename representing the dataset. The method must read all entries in the file, create a new instance of the Tweet object for every entry in the file and store in data structure. The 'loadAsArrayList' method should store all Tweet object as an ArrayList and returns the populated object. Similarly, the 'loadAsArray' method should store all Tweet object in an array (i.e. Tweet[]) and return it as its output. When implementing the loadAsArray method, you can assume that you do not know in advance the number of records in the file, so you must make sure you increase the size of the array as needed (i.e. double the size of the array if you reach its limit). Implement a Main class: you must create a Main class that demonstrates the functionality of the TweetLoader methods. Your 'main' method of the Main class should use the "loadAsArrayList' method to load the list of tweets stored from 'tweet_data.csv' in an ArrayList object. Moreover, it should use the LoadAsArray method to load the list of tweets stored from 'tweet_data.csv' in an Array. It should then invoke the displayHead and displayTail' methods to list to first n and last n entries respectively in each data structure. The Main class should also implement the following methods to print the content in the list: o public static void printHead(ArrayList list, int n) Display a list of the first n entries in the input ArrayList. o public static void printHead(Tweet[] list) Display a list of the first n entries in the input Array. o public static void printTail (ArrayList list) Display a list of the last n entries in the input ArrayList. o public static void printTail (Tweet[] list) Program Requirement Your implementation for the above program should comply with the following requirements and specifications: Your program should implement all the specification outlined above. Your code must be well organized, code must be indented. You must use the data file provided as input to your program. Source code files must be submitted (not the compiled files) You must use the template code provided. Your program must compile and run without errors and generate the expected output. Deliverables: You must submit your implementation of the Tweet.java, TweetLoader.java, the Main.java, an output screen showing your code executing and complete the Submission Cover Page for this assignment as listed on the LMS