请高手帮我查错!!我已经快疯了!

yellow007 2004-03-25 10:20:35
请高手帮我查错!!我已经快疯了!下面是代码,我用jcreator编译不行。

import java.io.*;
class decimal
{
public static void main(String[] args)
{
int a=0;
System.out.println("pls enter a digit:");
try
{
a=System.in.read();
}
catch(IOException e)
{
if(a<2){System.out.println("enter a (>=2)digit");
System.out.println(e);
}
boolean b=true;
for(int i=2;i<a;i++)
{
if(a%i==0){
b=false;
break;
}
}
if(b){System.out.println(a+" is a Decimal");}
else{System.out.println(a+" isnot a Decimal");}
/*int i=2;
while(a%i!=0&&i<a)
{
i++;
}
if(i==a){System.out.println(a+" is a Decimal");}
else{System.out.println(a+" is a Decimal");}*/
}
}
...全文
42 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yellow007 2004-03-26
  • 打赏
  • 举报
回复
非常very感谢,但java如何接受输入的数字,用System.in.read()返回的是ascii码值,不是输入的数字?
dengsf 2004-03-25
  • 打赏
  • 举报
回复
哈哈~~
===============================
catch(IOException e)
{
if(a<2){System.out.println("enter a (>=2)digit");
====这里少了==
System.out.println(e);
}
yellow007 2004-03-25
  • 打赏
  • 举报
回复
编译时,报错说少了‘}’。

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧