如何使用函数完成以下table?我快要解决了,但是我遇到了异常错误

How can I use functions to complete the following table? I came close to having it solved, but I'm getting exception errors

[SoloLearn 第 1 部分代码][SoloLearn 第 2 部分代码]1[My Take Home Assignment [][1]2` [弧度、正切、正弦、余弦和度数 Table

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);
    }
}

`

您使用 print f 的格式设置错误。也不需要导入扫描仪。 degree 是 int,但您提供了 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);
    }
}