Question: CPSC 1150: Lab 9 [35 marks] Objectives: 1. Write several methods that use and manipulate arrays 2. To become familiar with writing to and

CPSC 1150: Lab 9 [35 marks] Objectives: 1. Write several methods thatuse and manipulate arrays 2. To become familiar with writing to and

CPSC 1150: Lab 9 [35 marks] Objectives: 1. Write several methods that use and manipulate arrays 2. To become familiar with writing to and from files 3. To practice method decomposition, arrays, and file i/o Preamble The file releasedates.txt contains a list of video games and their release dates. Each line of the file contains the release date, a tab character, and then the name. The list is currently totally unsorted. The object of today's lab is to write a series of methods that allow us to perform the following tasks: read contents from a file and store them in array, sort the contents of the array by name or by date, and store the sorted array results back into a new text file. The first few lines of releasedates.txt look as follows: 04/26/16 07/14/16 06/24/16 Sega 3D Classics Collection Batman: Arkham Underworld Tokyo Mirage Sessions #FE File I/O [10 marks] 1. [5] Write the method String[] input(String filename) that accepts a file name as a parameter. This method should read in the data from the file and store it into an array, then return this array. 2. [5] Write the method void output(String filename, String[] info) that accepts a String called filename as a parameter. This method should create a new file called filename and write the contents of the array info neatly into the new file. Note: Your methods should work for any size of file. The file that the Lab Assistant will use to test your programs will not be the same releasedates.txt, and your program should work properly regardless. Sorting [15 marks] 1. Write the method String[] sortByMonth(String[] info). This method should sort the array from January release date to December release date and return it. 2. Write the method String[] sortByName(String[] info). This method should sort the array by game name from A to Z and return it. Note: you may not use any of Java's built in sort methods. Implement one of your favorites that we've covered in class so far. Using a built in sorting method will result in a mark of 0 for this portion of the lab. Hint: do not re-implement your sorting algorithm in each method, write one sorting method and then just call it in each of the above methods. Hint: you may find it easier to take the array of information and separate it into two new arrays, one for the list of games and one for the list of dates, and then perform the sort. It is important to make sure that the indexes of the arrays do not get out of sync, or you may lose the correct release dates for the different games. Main Program [5 marks] Your main program should call your input method on releasedates.txt. Your main program should call the sortBydate method, then write the result of that method call into a new file called SortedByDate.txt Your main program should call the sortByName method, then write the result of that method call into a new file called SortedByName.txt. Sample Output The first few lines of SortedByDate.txt should look exactly as follows: 01/04/16 01/05/16 01/05/16 Pony Island Amplitude Hardware: Rivals The first few lines of SortedByName.txt should look exactly as follows: 10 Second Ninja X 1979 Revolution: Black Friday 7 Days to Die 7th Dragon III Code: VFD[B] A Boy and His Blob A.W.: Phoenix Festa Submissions Make sure that your code is neat and all of your programs have the JavaDoc header described in Lecture 2-1! Each method must have proper internal Java Documentation - see Lecture 7-1 and the sample on D2L Week 7 [5 marks] Submit to D2L a zip/archive file containing the .JAVA files you have written for this lab (NOT .CLASS files) If you do not zip your file or if you submit the .class files, you will receive ZERO for this lab (http://www.wikihow.com/Zip-Files-Together)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The solution based on the information provided in the two images is the implementation of the Driver ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!