unc comp 110 fall 07.

Program 5: Where is Waldo?


Due: Thu Nov 15, 11:59 pm EST

Motivation

You are a detective and need to perform data analysis on data files. You are searching for Waldo. Waldo has left clues indicating cites he visited. Waldo keeps moving around, you need to identify the US states or country where he visited. This will help identify where he might go next.

Waldo has left clues encoded in files listing the latitude and longitude of the cities he visited. Latitude and longitude are coordinates on the globe. Here is a lat/long primer. To find the general region you must calculate the minimum and maximum latitude and longitude values. These values give a box around the region of the visits.

Given the latitude and longitude values, you can use this JavaScript map tool to identify the region.

Task

Write a Java program to find the boundary region. The program reads a data file and computes the minimum and maximum latitude and longitude values.

Requirements

Program 5 is based on the Java File recitation. In program 5, however, the data and computation is different.

There are requirements for your program so that the tester works properly. Your program class must be named WaldoData. The following methods are required (declared as listed).

public class WaldoData {

static public Scanner openFile(String filename)
static public void readFile(Scanner input)
static public String printOne(int index)
static public void displayData()
static public String calcBoundry()
public static void main(String[] args)
}

Mehtod printOne() returns a string (\t tab character):
latitude \t longitude

Method calcBoundry() returns a string with the min/max latitude and longitude values. . The files have two columns. The computation task is to find the minimum and maximum values for each column. That is find the minimum and maximum latitude in the first column and find the minimum and maximum longitude in the second column. The string format is (\t tab character):

Minimum lat \t min longitude \t max latitude \t max longitude
Example for state of NC (region Z)
33.86224	-81.678017	36.396061	-76.662468

The data file format is similar to the recitation:


Tester

For Java programs, the tester runs on your computer in Eclipse. Run the programmer in the tester (WaldoTester). The program will write results to the console like when your program runs.

Tester: WaldoTester.java

Using the tester requires an internet connection. The tester gets the test data from the COMP 110 web site.

Here are sample data files that your program reads in:  Use the JavaScript map tool to show where these regions are on a map.

Grading

We will grade your Java program based on the following:

Program Submission

Store your Java file (WaldoData.java) on your local disk until it's finished, then save it into your Onyen public_html directory. Save WaldoData.java in a directory using a secret 8-character name. Do not link your page to other pages in that directory.

Example
http://www.unc.edu/~onyern/c0d3wwwx/WaldoData.java

When your assignment is ready, you will submit your assignment through Blackboard.