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.

Hi
Actually I didn't read all the program but I found that you defined the static method sphericalDistance() as zero argument method which do not need an argument to work.

public static double sphericalDistance()

but when you call it in the main method you used an argument System.in with it.

public static void main (String[] args){
		sphericalDistance(System.in);
		}

I thing this is the problem.

you can either :
1. remove the argument System.in which you added to the method sphericalDistance() in main method.
i.e.

public static void main (String[] args){
		sphericalDistance();
		}

2. add the argument to an Input Stream argument to the method definition
i.e.

public static double sphericalDistance(InputStream is)

but you should first import the package java.io.InputStream by adding this code first

import java.io.InputStream

I prefer the first solution because you don't need the InputStream argument as I think.

Good luck

Okay, so now I have this (again, sorry for the sheer length):

import java.util.*;
public class TCSS142Prog3{
	
	public static final double kmToMiles = 0.621371192; //# of miles in a kilometer
	public static final double radius = 6372.795;
	public static void main (String[] args){
		double distanceRad = sphericalDistance(System.in);
		}
	public static double sphericalDistance(
	double location1_latitude_degrees,
	double location1_latitude_minutes,
	double location1_longitude_degrees,
	double location1_longitude_minutes,
	double location2_latitude_degrees,
	double location2_latitude_minutes,
	double location2_longitude_degrees,
	double location2_longitude_minutes){
		Scanner place = new Scanner (System.in);
		Scanner choose = new Scanner (System.in);
		double kmToMiles = 0.621371192; //# of miles in a kilometer
		double mile = 0.0;//establish mile as a constant
		double kilo = 0.0;//establish kilo as a constant
		int minuteDevision = 60;//establish minuteDevision as a constant
			//begin asking for information from user
			System.out.print("What is the latitude degree of the first location? "); //ask for latitude degrees
			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
			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
			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
			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
			location2_latitude_degrees = place.nextDouble(); //user enters longitude degrees
			System.out.print("Now the latitude minutes for the second location? "); //user enters latitude minutes
			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
			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
			location2_longitude_minutes = place.nextDouble(); //user enters longitude minutes
			double latOneFinal = (location1_latitude_minutes / minuteDevision) + location1_latitude_degrees; //convert minute to degrees and add latitudes together
			double longOneFinal = (location1_longitude_minutes / minuteDevision) + location1_longitude_degrees; //convert minutes to degrees and add longitudes together
			double latTwoFinal = (location2_latitude_minutes / minuteDevision) + location2_latitude_degrees;//convert minute to degrees and add latitudes together
			double longTwoFinal = (location2_longitude_minutes / minuteDevision) + location2_longitude_degrees;//convert minutes to degrees and add longitudes together
							
			latOneFinal=Math.toRadians(latOneFinal); //convert to radian
			latTwoFinal=Math.toRadians(latTwoFinal); //onvert to radian
			longOneFinal=Math.toRadians(longOneFinal); //convert to radian
			longTwoFinal=Math.toRadians(longTwoFinal); //convert to radian
			//finds # of radians between points
			double distance = Math.acos(Math.sin(latOneFinal)*Math.sin(latTwoFinal)+Math.cos(longOneFinal)*Math.cos
				(longTwoFinal)*Math.cos(longOneFinal - longTwoFinal)); //stores the rdistance in radians between locations in constant named distance
			System.out.println("The two locations you entered are " + convertToMile(distance) + "kilometers apart.");
			System.out.print("Or if you prefer, they are " + convertToKilo(distance) + "miles apart.");
			}
	public static double convertMile (double distance){
		double mile = (distance * radius) * kmToMiles; //distance in miles between points given
		return mile;
		}
	public static double convertTokKilo (double distance){
		double kilo = distance * radius; //finds how many kilometers the locations are apart
		return kilo;
		}
}

My error reads:

TCSS142Prog3.java:7: sphericalDistance(double,double,double,double,double,double,double,double) in TCSS142Prog3 cannot be applied to (java.io.InputStream)
double distanceRad = sphericalDistance(System.in);
^
TCSS142Prog3.java:45: cannot find symbol
symbol : variable distance
location: class TCSS142Prog3
System.out.println("The two locations you entered are " + convertToMile(distance) + "kilometers apart.");
^
TCSS142Prog3.java:46: cannot find symbol
symbol : variable distance
location: class TCSS142Prog3
System.out.print("Or if you prefer, they are " + convertToKilo(distance) + "miles apart.");
^
3 errors

How can I fix this? Anyone?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.