Unformatted text preview:

COMP 14.Assignment 6 (due July 23) Study by Student Health CentralStudy by Student Health Central (75p)Description of the problem:In this assignment you will be able to practice yet more with object-orientedprogramming, but you will also learn about:- Arrays of objects.- Reading and writing to files.- Sorting.The Student Health Central at UNC has conducted a study among internationalstudents to evaluate the incidence of depression on this subset of the student population.The result of the study is a T-score that indicates the scores of all participants.The T-score is stored in a file, following this format:(line 1) Number_of_participants(line 2) 1 Score_of_participant_1(line 3) 2 Score_of_participant_2(line 4) 3 Score_of_participant_3etc.Your job is to sort the information of this file according to the score of theparticipants. You will read the data in the file, sort it, and output it following this format:(line 1) Number_of_participants(line 2) Participant_number_a Score_of_participant_with_highest_score(line 3) Participant_number_b Score_of_participant_with_2nd_highest_score(line 4) Participant_number_c Score_of_participant_with_3rd_highest_scoreetc.Requirements and Grading:This assignment will be solved in an incremental way. You should return the .javafiles needed for each requirement in a different Java archive file (.jar).1. (10p) Open the file ints.txt. Read the number of values in the file. Create an arraybased on that information, and read all the values and store them in the array. Print all thevalues to another file. To be returned in File.jar2. (10p) Create and initialize an array of ints (feel free to choose the size of the array).Then code a method(s) to sort the array. Print the sorted array using System.out.println( ).To be returned in Sort.jar3. (10p) Same as 1, but sort the array before printing it to the output file. To bereturned in SortFile.jar4. (10p) Open the file study1.txt from the code directory on the webpage. Read thenumber of values in the file. Create an array of Participant objects based on thatinformation. Obviously, you need to define a class called Participant. Read the pairs ofvalues and store them in the Participant objects. Then print all the values to another file.To be returned in Participants.jar5a. (15p) Full assignment. Read the file study1.txt from the code directory on thewebpage. Store the data in an array of Participant objects. Sort the Participants. Print thesorted data. To be returned in SortParticipants.jar5b. (25p) Implement the full assignment in the following manner: in the mainmethod, create an object StudyManager, and perform all the main operations by callingmethods of the StudyManager object. The main() should look basically like a high-levelalgorithm, with only a few statements. All the complicated code should be inside theStudyManager class. To be returned in SortParticipants.jar* You will get 15p if you solve 5a but not 5b. You will get 25p if you solve 5b. Inthis case, you do not need to return a .jar file for 5a.* You will find several files on which you can test your program in the codedirectory on the webpage: study1.txt, study2.txt, study3.txt. They have differentamounts of participants.6. (10p) Write a report explaining:1) How do methods help in this problem? Imagine you were not allowed to writemethods, and everything had to be done in the main() method. What would be thedifficulties?2) How does object-oriented programming help? Imagine you were not allowed todefine classes and create objects. What would be the difficulties?Extra credit: Imagine that the study also gathered data about the country of origin.The study file would look like this (see study1wc.txt in the code directory):(line 1) Number_of_participants Number_of_countries(line 2) 1 Score_of_participant_1 Country_of_participant_1(line 3) 2 Score_of_participant_2 Country_of_participant_2(line 4) 3 Score_of_participant_3 Country_of_participant_3etc.The countries are just numbers from 1 to Number_of_countries, just like participantsare numbered from 1 to Number_of_participants.Think about what you would have to do to compute the average score per country:make a Country class containing the total score and number of participants in thatcountry, create an array of Country objects, go through the array of Participant objectsthat you read from the file, compute the total score for each country, and finally computethe average for each country.(40p) Change your program to read in this additional data and compute the additionalresults required.(10p) Write a short report on the difficulties you


View Full Document

UNC-Chapel Hill COMP 14 - Assignment 6

Download Assignment 6
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Assignment 6 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Assignment 6 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?