编译没问题,为什么通不过啊? java数据测试 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 for循环很可能死循环 没有跳出语句 也有健壮性问题吧//Testimport java.util.*;class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while(scanner.hasNext()) { int temp = 0; String str = null; try{ str = scanner.nextLine(); temp = Integer.parseInt(str);; while(temp >100000 || temp <0) { System.out.println("Please input a number between 0 and 100000!"); str = scanner.nextLine(); temp = Integer.parseInt(str); } }catch(NumberFormatException e) { System.out.println("You must input a number!"); e.printStackTrace(); } int num = 0; while(temp != 1) { if(temp % 2 == 0) { temp = temp / 2; }else { temp = (3*temp+1) / 2; } num ++; } System.out.println("num = " + num); } }} 管道流操作问题,求大虾解决!! 写的计算器布局 不知道怎么回事 显示出来的是一个框框 看不出哪错了 帮改改 关于流生成图片的问题,急~~ ResultSet.GETDATE()不能获取日期的时间部分 帮帮忙啊,各位高手们!!! JAVA中的方法如何实现可选参数??? 如何做工具栏,是用什么组件做的? 请问java里怎么把字符串转换成日期? 网络文件传送问题 一个简单的java问题,高分求助!!! 请问高手学习java中的困惑问题 急:求助java按序列编号排序(如1.2 ,1.11)
//Testimport java.util.*;class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while(scanner.hasNext()) {
int temp = 0;
String str = null;
try{
str = scanner.nextLine();
temp = Integer.parseInt(str);;
while(temp >100000 || temp <0) {
System.out.println("Please input a number between 0 and 100000!");
str = scanner.nextLine();
temp = Integer.parseInt(str);
}
}catch(NumberFormatException e) {
System.out.println("You must input a number!");
e.printStackTrace();
}
int num = 0;
while(temp != 1) {
if(temp % 2 == 0) {
temp = temp / 2;
}else {
temp = (3*temp+1) / 2;
}
num ++;
}
System.out.println("num = " + num);
}
}
}