IOException

hebin0819 2006-12-04 12:39:50
出学帮帮忙
import java.io.*;
class ky27{
public static void main(String args[])throws IOException {
int c;int a;
System.out.println("输入温度!");

while ((c=(int)System.in.read())!=' ')

switch ( c<10?1:c<25?2:c<35?3:4) {
case 1:
System.out.println(" "+c+"℃ 有点冷。");
break;
case 2:
System.out.println(" "+c+"℃ 正合适。");
break;
case 3:
System.out.println(" "+c+"℃ 有点热。");
break;
default:
System.out.println(" "+c+"℃ 太热了!开空调。");
}
}
}
...全文
107 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wlql 2006-12-04
  • 打赏
  • 举报
回复
变量c没有赋值
butnet 2006-12-04
  • 打赏
  • 举报
回复
import java.io.*;
import java.util.Scanner;
class ky27{
public static void main(String args[])throws IOException {
int c;int a;
System.out.println("输入温度!");
Scanner in=new Scanner(System.in);
while ((c=in.nextInt())!=-6000)
{
switch ( c<10?1:c<25?2:c<35?3:4) {
case 1:
System.out.println(" "+c+"℃ 有点冷。");
break;
case 2:
System.out.println(" "+c+"℃ 正合适。");
break;
case 3:
System.out.println(" "+c+"℃ 有点热。");
break;
default:
System.out.println(" "+c+"℃ 太热了!开空调。");
}//switch
}//while
}//main
}//class

62,612

社区成员

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

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