CPSC 1150: Lab 9 [35 marks] Objectives: 1. Write several methods that use and manipulate arrays...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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) 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)
Expert Answer:
Answer rating: 100% (QA)
The solution based on the information provided in the two images is the implementation of the Driver ... View the full answer
Related Book For
International Economics
ISBN: 978-1429278447
3rd edition
Authors: Robert C. Feenstra, Alan M. Taylor
Posted Date:
Students also viewed these programming questions
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
Certain merchandising transactions for Yule Park Gifts are listed below. November 2: Purchased 110 souvenir calendars at $9 each from Aloha Co. for cash Nov 4: Paid shipping costs $38 for the...
-
Describe what is meant by systematic and unsystematic risk. How is this distinction related to an investment's beta?
-
If financial intermediation breaks down, what category of GDP will probably fall the most: consumption, investment, government purchases, or net exports?
-
Consider a stochastic process described by the stochastic differential equation , where drift and volatility are piecewise constant functions of time (measured in years). For the first three years,...
-
Your boss, the IT director, wants you to explain FDDs, BPM, DFDs, and UML to a group of company managers and users who will serve on a systems development team for the new marketing system. 1....
-
Bond premium and bond discount are amortized over the life of the bond. What two methods are used for these amortizations, and how would the amortization amount be determined for each method?
-
E-portfolios are considered the authentic work-products of students and well-suited for self-assessment and peer-review (as a means of improving student learning). Why is this so, in your opinion?...
-
Best Poor Man's Country and Revolution What were the opportunities for individuals in this time period, share with the class the insights that you perceived about Pennsylvania? Did everyone have an...
-
You are right about any policy starting up needing a funding source. Determining where that funding will come from can be the hard part. It is important to map out a budget for the policy and promote...
-
What characteristics of a commonweal organization would likely conflict with the culture of a typical business organization that contracts to provide a public service?
-
1. Why did Mexicans volunteer for service during World War II? 2. What role did Mexican women play in the home front during the war? 3. What impact did urban living have on Mexicans? 4. Who were the...
-
summarize Economy God's economy not only relates to his provision of fundamental needs but also to the way humans consume resources. The Bible is very clear that people should only take what they...
-
What is the current status of airport and aviation security in terminals and in-flight? Provide an example(s) of any latest incident. Did the terminal have to shut down and were flights delayed?...
-
What is your assessment of the negotiations process, given what you have studied? What are your recommendations for Mr. Reed? You must justify your conclusions
-
Using the notation from the text, answer the following questions. You may assume that net labor income from abroad is zero, there are no capital gains on external wealth, and there are no unilateral...
-
The United States, France, and Italy are among the world's largest producers. To answer the following questions, assume that their markets are monopolistically competitive, and use the gravity...
-
Why is it necessary to use a market failure to justify the use of infant industry protection?
-
The finite element method was used to solve the truss problem shown below. The solution for displacements was obtained as \(u_{2}=1.5 \mathrm{~mm}, v_{2}=-1.5 \mathrm{~mm}, u_{3}=3 \mathrm{~mm}\),...
-
Use the finite element method to solve the plane truss shown in problem 29. Assume \(A E=\) \(2 \times 10^{6} \mathrm{~N}, L=1 \mathrm{~m}, \alpha=10 \times 10^{-6} /{ }^{\circ} \mathrm{C}\). The...
-
A rejection network that can be utilised instead of the twin-T network is the bridged-T network shown below. The transfer function of this network is given by \[...
Study smarter with the SolutionInn App