So i finished working on this but my project keeps giving me error message doesn't run. It does do some of the requirements but not all.
Build your project in NetBeans using the Run - Build Project, or Run - Clean and Build Project menu item.
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. See the sample input file.
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, args);
Here is a sample input file and a sample output file.
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/180Attachments
for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
Newfoundland:Burlington:49? 45' N:56? 1' W
Ontario:Burlington:43? 20' N:79? 48' W
Ontario:Waterloo:43? 30' N:80? 32' W
Quebec:Waterloo:45? 21' N:72? 31' W
British Columbia:Kamloops:50? 40' N:120? 21' W
Ontario:Markham:43? 53' N:79? 15' W
Ontario:Guelph:43? 33' N:80? 15' W
Ontario:Oshawa:43? 54' N:78? 51' W
Ontario:Peterborough:44? 18' N:78? 20' W
Nunavut:Alert:82? 28' N:62? 18'
<target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
9' N:80o 15' W
Ontario:Pickering:43o 50' N:79o 6' W
Ontario:Barrie:44o 23' N:79o 42' W
Ontario:Richmond:45o 12' N:75o 50' W
Ontario:Sudbury:46o 29' N:80o 60' W
Ontario:Burlington:43o 20' N:79o 48' W
Ontario:Waterloo:43o 30' N:80o 32' W
Ontario:Brockville:44o 36' N:75o 41' W
Ontario:Hamilton:43o 15' N:79o 52' W
Prince Edward Island:Victoria:46o 13' N:63o 28'
CityNode firstCity = new CityNode();
CityNode secondCity = new CityNode();
Scanner sc = new Scanner(System.in);
System.out.print("Enter the name of first city: ");
firstCity.city = sc.nextLine();
System.out.print("Enter the name of first province: ");
firstCity.province = sc.nextLine();
System.out.print("Enter the name of second
British Columbia:Vancouver:49? 17' N:123? 8' W
Ontario:Ottawa:45? 26' N:75? 42' W
Alberta:Edmonton:53? 33' N:113? 30' W
Alberta:Calgary:51? 2' N:114? 4' W
Nova Scotia:Halifax:44? 40' N:63? 36' W
Manitoba:Winnipeg:49? 54' N:97? 8' W
British Columbia:Victoria:48? 25' N:123? 22' W
Newfoundland:Victoria:47? 46' N:53? 13' W
Ontario:Victoria:43? 46' N:79? 52' W