2019/5/1 Programming Assignment #3

https://foothillcollege.instructure.com/courses/9422/assignments/240484 1/5

Programming Assignment #3

Due Wednesday by 7am Points 20 Available Apr 23 at 7am – Jul 7 at 11:59pm 3 months

Objec�ves: Update the class type(s): EnrollmentData. Use and modify the class TestEnrollmentData to tests the new addition(s). Practice exception handling.

Practice using two dimensional arrays.

Get in the habit of dividing larger projects into smaller parts.

Use git features such as commit and clone to write and read from your repository.

Material from: Program Guidelines, Reference: Lab Homework Requirements from Module. Multi-Dimensional Arrays:

Chapter 7 and 8 from Liang Textbook

Class TestEnrollmentData, example data files (included under the resource folder) in your assigned GitHub repository.

Applica�on Overview In the previous project we stored the Enrollment data from World Bank Open Data (https://data.worldbank.org/indicator/SE.SEC.NENR?view=chart) in a two-dimensional array. As a reminder the format of the CSV file is as follows:

Data Source,World Development Indicators,

Indicator,School Enrollment In Primary (% net)

Last Updated Date,[Date in MM/DD/YY format]

Number of countries [N number of countries]

Country Name,[year 1],[year 2]..[year M]

[country name 1],[data for year 1],[data for year 2]…[data for year M]

[country name 2],[data for year 1],[data for year 2]…[data for year M]

[country name N],[data for year 1],[data for year 2]…[data for year M]

We want to enable the user to ask the data questions. For example what was the enrollment period in “United States” from 2010 to 2015?https://foothillcollege.instructure.com/courses/9422/pages/program-guidelineshttps://foothillcollege.instructure.com/courses/9422/modules/99029https://data.worldbank.org/indicator/SE.SEC.NENR?view=chart

2019/5/1 Programming Assignment #3

https://foothillcollege.instructure.com/courses/9422/assignments/240484 2/5

Country Name,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017




“Egypt, Arab Rep.”,90.28288269,95.34037018,,95.98267365,97.1634903,93.17767334,96.87068939,,95.82694244,,97.45




Syrian Arab Republic,89.91343689,91.00061798,91.73821259,92.78222656,92.94094849,,,63.24472046,,,,

United States,93.09568024,94.49015808,95.11688995,93.85852814,92.71695709,91.9122467,92.05748749,91.74311829,9


The answer is in the highlighted area.

With the data of 8 countries over 12 years, answering the question above is not too difficult. But, hunting for the answer in the a larger data file would not be fun! The goal of this and the following programming assignment is to make this process easier.

The Program Spec Similar to before an object of type EnrollmentData contains a table containing all data for different countries.

class EnrollmentData Update the class EnrollmentData such that we can search the data table for the enrollment data the user requests.

A�ributes: A final int class variable called MISSING_DATA set to -1. Recall that class variables are labeled as static. Note: This is similar to the static variable in your test file. You can copy and paste the variable from the test file.

Methods The method getEnrollmentInCountryForPeriod() which determines if the requested year range is valid. If the request is invalid:

First display a message specifying which request is invalid. Then adjust the start and end year to the overlap between the requested and valid start and end years. Then return a one dimensional array of double for the enrollment data of the given country name between the requested start year and end year (inclusive).

2019/5/1 Programming Assignment #3

https://foothillcollege.instructure.com/courses/9422/assignments/240484 3/5

NOTE: Your implementation must handle the case when start year or end year is out of range. If no, data exists between the given years then return null (see clarification** below).

Takes three arguments: A String for the country name to search for.

An int for the requested starting year

An int for the requested ending year (inclusive).

Returns a one dimensional array of type double.

**Note: Recall from the above section titled Application Overview that data submitted by a country is voluntary. As are result some cells maybe empty. So, what should we do if the user request is valid, but no data exists between the requested start and end years?

Well this depends on our implementation. In this project since we are dealing with an array of primitives. Instead of returning a one dimensional array of doubles filled with arbitrary values, return a single dimensional array of doubles filled the MISSING_DATA value That way the user knows that their request is valid, but there is no data available.

Throws an IllegalArgumentException in case a valid period does not exist between the requested start and end years.

Invalid Assumptions:

Do not: Limit the number of countries (i.e. number of rows), Limit the number of years (i.e. number of columns), Limit the starting year and ending year.

class TestEnrollment Add at least two test cases beyond those provided by checking to make sure your implementation can handle valid and invalid requests when calling the getEnrollmentInCountryForPeriod() method.

Dis�nguishing Test Cases Clearly distinguish the different test cases.

Suggestion: Use the following template for your RUN.txt file:

2019/5/1 Programming Assignment #3

https://foothillcollege.instructure.com/courses/9422/assignments/240484 4/5

As always you may create as many additional classes, attributes and methods as you need keeping in mind that the original test file provided in your assigned repository must compile and run successfully. See FAQs below.

Reminder As a reminder…In order to receive full credit on this assignment, your program must:

1. Follow all Program Guidelines, see Modules for the guidelines.

2. Get the correct results when the main() application is run. Here this is in the test class.

3. Include the following in your lab submission: The source code: the listing of your program under the src directory. Do not change the package name of the provided class.

Comment all classes and all methods. Then, generate Javadocs and include it in your submission. Note: For this project we only have one class and one method. Reminder: A brief tutorial on generating Javadocs is included in the Introductions module section Example Program Submission.

Run output sample(s): in a plain-text file called RUN.txt (For now, the output should be only plain-text);

A brief description of all files submitted: in a plain-text file called README.txt.



Test file: resources/dataFile01.txt

NOTES: Testing data file with a subset of countries

and enrollment ranges.

Testing valid data ranges.


[Paste your output here.]



Test file: resources/dataFile02.txt

NOTES: Testing data file with all data.

Testing valid and invalid enrollment data ranges.


2019/5/1 Programming Assignment #3

https://foothillcollege.instructure.com/courses/9422/assignments/240484 5/5

FAQ: Can I include additional attributes, methods and or classes?

Yes, add as many as you see fit outside of the test class. The exception is if the project description requires that you define a method.

Keep in mind that I run two test files when checking your work:

1) I first run your test file (i.e. the one you submit and perhaps modify).

2) Then, I run the instructor test file, which will be testing for different input.

If your test class creates and depends on classX or methodY(), but the original test class (i.e. one or more test classes that you received as the starting code in your assigned repository) had never created an object of type classX or called methodY(), then the result will be compilation errors in the instructor test class. This is because the interfaces the instructor test class relies on is the same interfaces (i.e. class types and method calls) as the original test class (es).

In general, do *not* change method signatures. This includes:

the package name,

list of file imports,

visibility of methods,

capitalization of method names,

order of arguments,

handling of exceptions, etc.

I will not be grade your project if it results in compilation or runtime errors.

FAQ: Can I change the main() method?

The test class TestEnrollment has mostly already been written for you. Add your test cases. However, do not change method main() in the TestEnrollment class such that it creates dependencies.

"Get 15% discount on your first 3 orders with us"
Use the following coupon

Order Now