关于sololearn的代码第1部分][关于sololearn的代码第2部分][弧度、正切、正弦、余弦和度数表 import java.util.Scanner; public class St_Johns_University { public static void main(String[] args) { System.out.printf("%-10s%-10s%-10s%-10s%-10s\n", "Radians", "Tangent", "Sine", "Cosine", "Degrees");
int degrees = 60;
double radians = Math.toRadians(degrees);
System.out.printf("%-10d%-10.4f%-10.4f%-10.4f%-10.4f\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
degrees = 80;
radians = Math.toRadians(degrees);
System.out.printf("%-10d%-10.4f%-10.4f%-10.4f%-10.4f\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
degrees = 100;
radians = Math.toRadians(degrees);
System.out.printf("%-10d%-10.4f%-10.4f%-10.4f%-10.4f\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
degrees = 130;
radians = Math.toRadians(degrees);
System.out.printf("%-10d%-10.4f%-10.4f%-10.4f%-10.4f\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
degrees = 160;
radians = Math.toRadians(degrees);
System.out.printf("%-10d%-10.4f%-10.4f%-10.4f%-10.4f\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
}
}
您使用打印f进行格式化是错误的。另外,不需要导入扫描仪。度是整数,但是您提供了f而不是d并且还提供了精度4.弧度是两倍。但您提供的d是错误的,我已更正,请检查以下代码。
public class St_Johns_University { public static void main(String[] args) { System.out.printf("%-10s%-10s%-10s%-10s%-10s\n", "Radians", "Tangent", "Sine", "Cosine", "Degrees");
int degrees = 60;
double radians = Math.toRadians(degrees);
System.out.printf("%-10f%-10.4f%-10.4f%-10.4f%-10d\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
degrees = 80;
radians = Math.toRadians(degrees);
System.out.printf("%-10f%-10.4f%-10.4f%-10.4f%-10d\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
degrees = 100;
radians = Math.toRadians(degrees);
System.out.printf("%-10f%-10.4f%-10.4f%-10.4f%-10d\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
degrees = 130;
radians = Math.toRadians(degrees);
System.out.printf("%-10f%-10.4f%-10.4f%-10.4f%-10d\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
degrees = 160;
radians = Math.toRadians(degrees);
System.out.printf("%-10f%-10.4f%-10.4f%-10.4f%-10d\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
}
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。