gpt4 book ai didi

java - 为什么我的正弦方法不起作用

转载 作者:行者123 更新时间:2023-12-01 11:38:46 25 4
gpt4 key购买 nike

我是一名初级程序员,也是 stackoverflow 的新手。

所以我一直在制作一个数学公式求解器,并且我有 4 个公式并正在运行。我正在研究我的正弦公式求解器,但它不起作用。我使用扫描仪和开关来选择公式并输入变量。这是我所拥有的。

Scanner input = new Scanner(System.in);
System.out.println("Enter '0' for list of formula call numbers");
System.out.print("Enter the formula request number: " );
int mFormula = input.nextInt();
switch(mFormula)
{
case 5 :
System.out.println("Sine Problem Solver, please enter your variables below: ");
System.out.println();
System.out.print("Value for known side: ");
int x = input.nextInt();
System.out.println();
System.out.print("Value for degrees: ");
int x3 = input.nextInt();
System.out.println();
double Sine = (x * Math.sin(x3));
System.out.print("The side length is: " + Sine);break;
}

我真的很困惑为什么它不起作用。

最佳答案

看来你的主要问题是 Math.sin 不采用度数而是弧度。尝试一下

Math.sin(Math.toRadians(x3))

关于java - 为什么我的正弦方法不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29732468/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com