This is basically to request help with my program, as was already evident. I am a student, and an assignment asks me to "Write a method that computes the spherical distance between two points on the surface of the earth, given their latitudes and longitudes."
I have written this so far (I also apologize if it looks extremely long. we have not covered in class methods of shortening it):
import java.util.*;
public class TCSS142Prog3{
public static void main (String[] args){
sphericalDistance(System.in);
}
public static double sphericalDistance(){
Scanner place = new Scanner (System.in);
double radius = 6372.795;
double latOneFinal = 0.0;
double longOneFinal = 0.0;
double latTwoFinal = 0.0;
double longTwoFinal = 0.0;
double distanceKm = 0.0;
double distanceMi = 0.0;
int minuteDevision = 60;
//begin asking for information from user
System.out.print("What is the latitude degree of the first location? "); //ask for latitude degrees
double location1_latitude_degrees = place.nextInt(); //user enters latitude degrees
System.out.print("What are the latitude minutes of the first location? ");//ask for latitude minutes
double location1_latitude_minutes = place.nextDouble(); //user enters latitude minutes
System.out.print("What is the longitude degree of the first location? "); //ask for longitude degrees
double location1_longitude_degrees = place.nextDouble(); //user enters longitude degrees
System.out.print("What are the longitude minutes of the first location? "); //ask for longitude minutes
double location1_longitude_minutes = place.nextDouble(); //user enters longitude minutes
System.out.print("Okay, good.\nNow what is the latitude degree for the second location?");//asks for longitude degrees
double location2_latitude_degrees = place.nextDouble(); //user enters longitude degrees
System.out.print("Now the latitude minutes for the second location?"); //user enters latitude minutes
double location2_latitude_minutes = place.nextDouble(); //user enters latitude minutes
System.out.print("And what is the longitude degree for the second location?"); //asks for longitude degrees
double location2_longitude_degrees = place.nextDouble(); //user enters longitude degrees
System.out.print("And finally the longitude minutes for the second location?"); //ask for longitude minutes
double location2_longitude_minutes = place.nextDouble(); //user enters longitude minutes
latOneFinal = (location1_latitude_minutes / minuteDevision) + location1_latitude_degrees;
longOneFinal = (location1_longitude_minutes / minuteDevision) + location1_longitude_degrees; //convert minutes to degrees and add latitudes together
latTwoFinal = (location2_latitude_minutes / minuteDevision) + location2_latitude_degrees;
longTwoFinal = (location2_longitude_minutes / minuteDevision) + location2_longitude_degrees;
latOneFinal=Math.toRadians(latOneFinal);
latTwoFinal=Math.toRadians(latTwoFinal);
longOneFinal=Math.toRadians(longOneFinal);
longTwoFinal=Math.toRadians(longTwoFinal);
Math.acos(Math.sin(latOneFinal)*Math.sin(latTwoFinal)+Math.cos(longOneFinal)*Math.cos(longTwoFinal)*Math.cos(longOneFinal - longTwoFinal));
}
}
I have yet to write the return part, but for some reason when I compile this part I get the error:
TCSS142Prog3.java:5: sphericalDistance() in TCSS142Prog3 cannot be applied to (java.io.InputStream)
sphericalDistance(System.in);
^
1 error
What does this mean and how might I fix it, or is the issue just that the return statement is missing? If this is the case....how would I write the return statement? I feel like I have coded myself into a pit which i do not know how to climb out of.