DOC PREVIEW
UNF COP 2551 - Study Notes

This preview shows page 1 out of 2 pages.

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

Unformatted text preview:

COP 2551 – Introduction to OOP Program #5Due: Friday, 30 July 2010 midnight There is no drop-dead date due to end of semester.Using NetBeans 6.8, you are to write a Java program using OOP principles to accommodate the following functionalityUsing the input file States.txt, you are to build a 4 by X array of integers, average the numbers in each row and display the array and averages. (If you wish, you may use ArrayList).Each record in the input file has two fields of interest to you: the region number and the population. (You will need a substring to extract those two numbers, as in Program 4)Task 1: Build a Two-Dimensional Array. Build a 4by X array such that each row contains a list of integers for populations of statesin ‘that’ region. Specifically, row 1 would have six columns: 480000 720000 500000 100000 1360000 and 15000 (or some such numbers) namely arrayName (0,0), (0,1), (0,2), etc. that is, all the populations from state that were in region 1. Your second row will have all the populations from those states that are in region 2, etc. Since there are only four regions that we are considering, your two-dimensional array will have four rows. The number of columns depends on the number of states in that region. Thus you will have a ragged array.Task 2: Print out the Two-Dimensional Array.You may use the routines in your book discussed at length in class. These are very close to exactly what you will need. See comments below on printing out headers to make this look nice.Task 3: Average the populations per row.Write a method that expects you to pass it a single row of the array, like the parameter: arrayName[i] and returns the average population of those states in that row (or equivalently in that Region. Call the method four times, once for each row in your array. Each time you call this method, pass the average population back to main each time as aninteger.Task 4: Print the average population of each regionWhen the method described in task 3 returns the integer population, merely print out this integer. For all tasks: Please do format the output and all outputs with a header that clearly describes the detail lines underneath.Task 5. Go through each region (row) to determine the state with the largest population. Display this nicely with an appropriate header. Use your professional judgment as to the header. Then, skip a line and print the state with the overall largest population. Display its output nicely too (this means commas, spacing, justification, etc.).That’s


View Full Document

UNF COP 2551 - Study Notes

Download Study Notes
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 Study Notes 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 Study Notes 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?