这个程序无结果??
import java.util.Scanner;public class gaohaoA {
public static void main(String args[]) {
Scanner reader = new Scanner(System.in);
double a = 0,b = 0,c = 0;
System.out.print("输入边a:");
a = reader.nextDouble();
System.out.print("输入边b:");
b = reader.nextDouble();
System.out.print("输入边c:");
c = reader.nextDouble();
if(a + b > c && b + c > a && a + c > b) {
if(a*a == b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b) {
System.out.printf("%-8.3f%-8.3%-8.3f构造是直角三角形",a,b,c);
}
else if(a*a < b*b + c*c && b*b < a*a + c*c && c*c < a*a + b*b) {
System.out.printf("%-8.3f%-8.3%-8.3f构造是锐角三角形",a,b,c);
}
else {
System.out.printf("%-8.3f%-8.3%-8.3f构造是钝角三角形",a,b,c);
}
}
else {
System.out.printf("%f,%f,%f不构成三角形",a,b,c);
}
}
}
会出现如下结果:
输入边a:3
输入边b:4
输入边c:5
Exception in thread "main" java.util.IllegalFormatPrecisionException: 3
at java.util.Formatter$FormatSpecifier.checkText(Formatter.java:2940)
at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2647)
at java.util.Formatter.parse(Formatter.java:2480)
at java.util.Formatter.format(Formatter.java:2414)
at (PrintStream.java:920)
at (PrintStream.java:821)
at gaohaoA.main(gaohaoA.java:14)