最近ここに投稿しましたが、やはり助けが必要です (私は非常に新しいです) 最初の部分 (SSS) を取得しましたが、2 番目の部分は助けが必要です。a² = b² + c² の入れ方がわかりません- 2bc cosA in and sin B / b = sin A / a ここに私のコードがあります:
import java.util.Scanner;
public class CosineLaw {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
boolean sss = new Boolean(true);
System.out.println("Are you working with an SSS?[y/n]");
char askingSSS =keyboard.next().charAt(0);
if(askingSSS == 'y'){
System.out.println("Please enter an a side value:");
double a = keyboard.nextDouble();
System.out.println("Please enter a b side value:");
double b = keyboard.nextDouble();
System.out.println("Please enter a c side value:");
double c = keyboard.nextDouble();
double answerA = Math.toDegrees(Math.acos((b*b+c*c-a*a) / (2*b*c)));
double answerB = Math.toDegrees(Math.acos((c*c+a*a-b*b) / (2*c*a)));
double answerC = Math.toDegrees(Math.acos((b*b+a*a-c*c) / (2*b*a)));
System.out.println("A: " + answerA);
System.out.println("B: " + answerB);
System.out.println("C: " + answerC);
}else if(askingSSS == 'n'){
System.out.println("Are you working with SAS?[y/n]");
char askingSAS =keyboard.next().charAt(0);
System.out.println("Please enter the 2 sides and 1 angle:");
char twoSideOneAngle =keyboard.next().charAt(0);
if(askingSAS == 'y'){
System.out.println("Please enter an angle for a:");
double a = keyboard.nextDouble();
System.out.println("Please enter a side value for b:");
double b = keyboard.nextDouble();
System.out.println("Please enter a side value for c:");
double c = keyboard.nextDouble();
double answerA = Math.cos(Math.toDegrees(b*b+c*c-2*b*c)*(a));
double answerB = Math.sin(Math.toDegrees(sin b/b = sin a/a));
double answerC = (b*b+a*a-c*c) / (2*b*a);
System.out.println("A: " + answerA);
System.out.println("B: " + answerB);
System.out.println("C: " + answerC);
}
}
}
}