DOC PREVIEW
UNC-Chapel Hill COMP 14 - Assignment 6

This preview shows page 1 out of 3 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

COMP 14 Assignment 6 due July 23 Study by Student Health Central Study by Student Health Central 75p Description of the problem In this assignment you will be able to practice yet more with object oriented programming 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 international students 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 3 etc Your job is to sort the information of this file according to the score of the participants 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 score etc Requirements and Grading This assignment will be solved in an incremental way You should return the java files 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 array based on that information and read all the values and store them in the array Print all the values to another file To be returned in File jar 2 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 jar 3 10p Same as 1 but sort the array before printing it to the output file To be returned in SortFile jar 4 10p Open the file study1 txt from the code directory on the webpage Read the number of values in the file Create an array of Participant objects based on that information Obviously you need to define a class called Participant Read the pairs of values and store them in the Participant objects Then print all the values to another file To be returned in Participants jar 5a 15p Full assignment Read the file study1 txt from the code directory on the webpage Store the data in an array of Participant objects Sort the Participants Print the sorted data To be returned in SortParticipants jar 5b 25p Implement the full assignment in the following manner in the main method create an object StudyManager and perform all the main operations by calling methods of the StudyManager object The main should look basically like a high level algorithm with only a few statements All the complicated code should be inside the StudyManager 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 In this 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 code directory on the webpage study1 txt study2 txt study3 txt They have different amounts of participants 6 10p Write a report explaining 1 How do methods help in this problem Imagine you were not allowed to write methods and everything had to be done in the main method What would be the difficulties 2 How does object oriented programming help Imagine you were not allowed to define 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 3 etc The countries are just numbers from 1 to Number of countries just like participants are 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 that country create an array of Country objects go through the array of Participant objects that you read from the file compute the total score for each country and finally compute the average for each country 40p Change your program to read in this additional data and compute the additional results required 10p Write a short report on the difficulties you encountered


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 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?