babyone
学会思考,学会做人
发贴: 49
积分: 0
|
于 2004-09-10 08:59
//============================================== // 程序名称:Zero.java // 程序目的:判断一个浮点数是否等于0 //============================================== import java.io.*; public class Zero { public static void main(String[] args) { Float x; System.out.println("请输入一个浮点数x="); InputStreamReader i=new InputStreamReader(System.in); BufferedReader b=new BufferedReader( i ); x=Float.parseFloat( b ); if (x==0) System.out.println("浮点数x="+x"等于0"); else System.out.println("浮点数x="+x"不等于0"); } }
当我编译这个程序的时候,出现一下错误 : ---------------- JDK Debug Build ------------------ Compiling C:\Documents and Settings\user\My Documents\Modelworks\MyProjects\Zero.java Command line: "C:\j2sdk1.4.1\bin\javac.exe" -deprecation -g -classpath C:\DOCUME~1\user\MYDOCU~1\MODELW~1\MYPROJ~1 "C:\Documents and Settings\user\My Documents\Modelworks\MyProjects\Zero.java" The current directory is: C:\Documents and Settings\user\My Documents\Modelworks\MyProjects C:\Documents and Settings\user\My Documents\Modelworks\MyProjects\Zero.java:21: ')' expected System.out.println("浮点数x="+x"等于0"); ^ C:\Documents and Settings\user\My Documents\Modelworks\MyProjects\Zero.java:23: ')' expected System.out.println("浮点数x="+x"不等于0"); ^ C:\Documents and Settings\user\My Documents\Modelworks\MyProjects\Zero.java:18: parseFloat(java.lang.String) in java.lang.Float cannot be applied to (java.io.BufferedReader) x=Float.parseFloat(b); ^ C:\Documents and Settings\user\My Documents\Modelworks\MyProjects\Zero.java:20: operator == cannot be applied to java.lang.Float,int if (x==0) ^ 4 errors Finished 那位能给我在我原程序的基础上最少改动的建议 ! 我在此叩谢了 !
|