我如何使我的计算器以度量而不是弧度计算
我一直陷入困境很长一段时间。我如何使计算器以度而不是弧度计算。我尝试了Math.todegrees,但它不起作用。如果您决定提供帮助,谢谢。
导入Java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// END USER INPUT VALUE IN DEGREES
System.out.println("Please input a value to recieve the Trigonemetric value in degrees ");
double degrees = scanner.nextDouble();
double sineOfAngle = Math.sin(degrees);
double cosOfAngle = Math.cos(degrees);
double tanOfAngle = Math.tan(degrees);
System.out.println();
System.out.println("The Sine of " + degrees + " degrees is : "
+ sineOfAngle);
System.out.println("The Cosine of " + degrees + " degrees is : "
+ cosOfAngle);
System.out.println("The Tangent of " + degrees + " degrees is : "
+ tanOfAngle);
}
}
I have been stuck on this for a very long bit of time. How do I make my calculator calculate in degrees rather than radians. I tried Math.toDegrees but it did not work. Thank you if you decide to help.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// END USER INPUT VALUE IN DEGREES
System.out.println("Please input a value to recieve the Trigonemetric value in degrees ");
double degrees = scanner.nextDouble();
double sineOfAngle = Math.sin(degrees);
double cosOfAngle = Math.cos(degrees);
double tanOfAngle = Math.tan(degrees);
System.out.println();
System.out.println("The Sine of " + degrees + " degrees is : "
+ sineOfAngle);
System.out.println("The Cosine of " + degrees + " degrees is : "
+ cosOfAngle);
System.out.println("The Tangent of " + degrees + " degrees is : "
+ tanOfAngle);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
Math.toradians()
,您想将学位转换为弧度,因为数学三角函数参数应在弧度中:use
Math.toRadians()
, You want to convert the degrees to radians because the Math trigonometric functions parameters should be in radians:你为什么需要那个?编程语言将始终使用弧度进行计算。您可以以度量接受输入,然后将其转换为弧度,进行计算并将其转换回输出程度。
Why you need that? Programming language will always use radians for calculation. You can accept input in degrees, then convert it to radians, make calculation and convert it back to degrees on output.