Java语言程序设计 小白求帮助

System.out.printf怎么用,为什么我打出来会报错

    System.out.printf("%-10s%-10s%-10s%-10s%-10s\n", "Degrees", "Radians", "Sine", "Cosine", "Tangent");
    int degrees = 30;
    double radians = Math.toRadians(degrees);
    System.out.printf("%-10d%-10.4f%-10.4f%-10.4f%-10.4\n", degrees,
      radians, Math.sin(radians), Math.cos(radians),
      Math.tan(radians));

    degrees = 60;
    radians = Math.toRadians(degrees);
    System.out.printf("%-10d%-10.4f%-10.4f%-10.4f%-10.4\n", degrees,
              radians, Math.sin(radians), Math.cos(radians),
              Math.tan(radians));

3个回答

你应该把你的代码附上来看看

qq_36571520
qq_36571520 附好了,求大神指教
大约 3 年之前 回复

你是bdqn Android班的吧

qq_36571520
qq_36571520
大约 3 年之前 回复

你少了参数
System.out.printf("%-10s%-10s%-10s%-10s%-10s\n", "Degrees", "Radians",
"Sine", "Cosine", "Tangent");
int degrees = 30;
double radians = Math.toRadians(degrees);
System.out.printf("%-10d%-10.4f%-10.4f%-10.4f%-10.4f\n", degrees,
radians, Math.sin(radians), Math.cos(radians),
Math.tan(radians));

    degrees = 60;
    radians = Math.toRadians(degrees);
    System.out.printf("%-10d%-10.4f%-10.4f%-10.4f%-10.4f\n", degrees,
            radians, Math.sin(radians), Math.cos(radians),
            Math.tan(radians));

            你对照一下吧,第二个和第三个输出的参数,你少了个F
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!