このメソッドは、String、double、および String の 3 つの引数を受け入れることになっています。そして、メインメソッドで出力される値を返します。どうすればいいですか?これが私がしたことです
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
public class coordinates
{
public static void main(String args[])
{
double angle=0, az = 0;
JOptionPane.showMessageDialog(null, "Hello, this is the 'Bearing to Azimuth' converter.\nFirst, you must input whether the angle is from the North or from the South, input the angle, and then input whether it is East or West.", "Bearing to Azimuth converter", JOptionPane.PLAIN_MESSAGE);
String ns = JOptionPane.showInputDialog("Input n for North and s for South:");
String inputangle = JOptionPane.showInputDialog("Input the angle in decimal format:");
angle = Double.parseDouble(inputangle);
String ew = JOptionPane.showInputDialog("Input e for East and w for West:");
convertToSouthAzimuth(ns, angle, ew);
JOptionPane.showMessageDialog(null, "The converted azimuth is " + az, "Bearing to Azimuth converter", JOptionPane.PLAIN_MESSAGE);
} //end main method
public double convertToSouthAzimuth(String ns, double angle, String ew)
{
double az = 0;
if (ns.equals("n")||ns.equals("N")) {
if (ew.equals("e")||ew.equals("E")) {az= 180+angle;}
if(ew.equals("w")|| ew.equals("W")){az= 180-angle;}
}
if (ns.equals("s")||ns.equals("S")) {
if (ew.equals("e")||ew.equals("E")) {az= 360-angle;}
if (ew.equals("w")||ew.equals("W")) {az= angle;}
}
return az;
} //end convertToSouthAzimuth method
}