编译能够通过,可是一运行就出现异常了
这个是我的程序:
import java.util.*;
public class example
{
public static void main(String args[])
{
Scanner reader=new Scanner(System.in);
double a=0,b=0,c=0;
System.out.println( "输入边a: ");
a=reader.nextDouble();
System.out.println( "输入边b: ");
b=reader.nextDouble();
System.out.println( "输入边c: ");
c=reader.nextDouble();
if(a+b> c&&a+c> b&&c+b> a)
{
if(a*a==b*b+c*c||a*a==c*c+b*b||b*b==c*c+a*a)
{
System.out.printf( "\n%%10.3f%10.3f%103.f构成直角三角形 ",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( "\n%%10.3f%10.3f%103.f构成锐角三角形 ",a,b,c);
}
else
{
System.out.printf( "\n%%10.3f%10.3f%103.f构成钝角三角形 ",a,b,c);
}
}
else
{
System.out.printf( "\n%%10.3f%10.3f%103.f不构成三角形 ",a,b,c);
}
}
}
这个是异常:
输入边a:
3
输入边b:
4
输入边c:
5
Exception in thread "main " java.util.UnknownFormatConversionException: Conversion = '1 '
at java.util.Formatter.checkText(Formatter.java:2500)
at java.util.Formatter.parse(Formatter.java:2482)
at java.util.Formatter.format(Formatter.java:2411)
at java.io.PrintStream.format(PrintStream.java:899)
at java.io.PrintStream.printf(PrintStream.java:800)
at example.main(example.java:23)
Press any key to continue...
------解决方法--------------------------------------------------------
\n%%10.3f%10.3f%103
不支持 这些格式字符