Price: $5 USD

Question description

Build your project in NetBeans using the Run - Build Project, or Run - Clean and Build Project menu

From the dist directory you will execute your program from the command line with two filenames as
arguments, input file name and output file name. For example:

java -jar lab5.jar..\input.txt ..\output.txt

Write a java program that will prompt the user for two city and province names from a select list.

Read each of the records from the input file and extract the two records that match those
requrested by the user.

Define a class named Cruncher which will do all the 'heavy lifting' in this program.

The main line of your solution will look exactly like this:

public static void main(String[] args)
  if(args.length < 2)
  System.err.println("Usage: java -jar lab5.jar infile outfile");

  Cruncher dataManipulator = new Cruncher(args[0], args[1]);


Latitude is measured in degrees and minutes with zero at the equator and 90 degress at the North pole or South pole. Latitude has to be expressed as North or South. There is usually a third number, seconds but it is not in our data, just degrees and minutes. Longitude is also measured in degrees and minutes with zero located a little outside London England (Greenwich). Longitude must be expressed as West or East and it ranges from zero to 180 degrees. All the data in Canada will be North and West and simplifies our calculation a little bit.

Here is the code to calculate the distance between two cities given longitude and latitude:

double earthRadius = 6371;  // in km
  double distance = Math.acos(Math.sin(Lat1) * Math.sin(Lat2) +
  Math.cos(Lat1) * Math.cos(Lat2) *
  Math.cos(Long2 - Long1)) * earthRadius;

The values you feed into the trig functions are in radians. You will be reading
strings of text in degrees and minutes. So your program will have to convert
strings to doubles as degrees and minutes and then convert those doubles to
decimal degrees and then convert that to radians. Here is a non-Java
description of what I mean:

degree = 23
minute = 45
decimaldegree is then 23.75 because there are 60 minutes in a degree ( our data does not have seconds )
radians = decimaldegree * PI/180

Studypool has helped 1,244,100 students
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1824 tutors are online

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors