You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
plfbyct68/SanJiaoHanShu.java

38 lines
729 B

package calculator;
import java.util.*;
import java.math.*;
public class Calculate {
public static void main(String[] args) {
//System.out.println("function:"); /*输入函数符号*/
Scanner function= new Scanner(System.in); /*输入角度数*/
String str=function.nextLine();
//System.out.println("radian:");
Scanner radian= new Scanner(System.in);
double d=radian.nextDouble();
if(str.equals("sin")) {
System.out.println("="+Math.sin(Math.toRadians(d)));
}
else if(str.equals("cos")) {
System.out.println("="+Math.cos(Math.toRadians(d)));
}
else if(str.equals("tan")) {
System.out.println("="+Math.tan(Math.toRadians(d)));
}
else System.out.println("Error!");
}
}