Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 小虾求教:这个程序是不是某个地方出问错了 ?
babyone

学会思考,学会做人



发贴: 49
积分: 0
于 2004-09-10 08:59 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
//==============================================
// 程序名称: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
那位能给我在我原程序的基础上最少改动的建议 ! 我在此叩谢了 !




话题树型展开
人气 标题 作者 字数 发贴时间
3863 小虾求教:这个程序是不是某个地方出问错了 ? babyone 1671 2004-09-10 08:59
3084 Re:小虾求教:这个程序是不是某个地方出问错了 ? why 695 2004-09-10 12:28
3079 Re:小虾求教:这个程序是不是某个地方出问错了 ? flywithmoon 16 2004-09-10 14:34
3324 Re:小虾求教:这个程序是不是某个地方出问错了 ? babyone 774 2004-09-10 16:17
3090 Re:小虾求教:这个程序是不是某个地方出问错了 ? why 535 2004-09-10 21:36
3437 Re:小虾求教:这个程序是不是某个地方出问错了 ? babyone 32 2004-09-10 23:39

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923