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

您没有登录

» Java开发网 » Java SE 综合讨论区 » 实战错误讨论  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 为什么不运行?
huzi01245





发贴: 1
积分: 0
于 2007-03-27 20:21 user profilesend a private message to usersend email to huzi01245search all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
import java.io.*;
public class tongji {

public static void main(String[] args) //throws IOException
{
String str1,str2,str3,str4,str5;
int x=0,z=0,i=0,y=0;
int a[]=new int[5];
BufferedReader buf;
buf=new BufferedReader(new InputStreamReader(System.in));
System.out.print("输入成绩:");
str1=buf.readLine();
a[0]=Integer.parseInt(str1);
System.out.print("输入成绩:");
str2=buf.readLine();
a[1]=Integer.parseInt(str2);
System.out.print("输入成绩:");
str3=buf.readLine();
a[2]=Integer.parseInt(str3);
System.out.print("输入成绩:");
str4=buf.readLine();
a[3]=Integer.parseInt(str4);
System.out.print("输入成绩:");
str5=buf.readLine();
a[4]=Integer.parseInt(str5);
do
{
if (a[i]<0 || a[i]>100)
//JOptionPane.showMessageDialog(null, "shurucuowu!");
System.out.print("输入错误!");
if (a[i]>=0 && a[i]<60)
x=x+1;
if (a[i]>=60 && a[i]<=75)
y=y+1;
if (a[i]>75 && a[i]<=100)
z=z+1;
i++;
}while(i<5);
System.out.println("A="+z);
System.out.println("B="+y);
System.out.println("C="+x);
}


}
可以正常运行。但是下面的就不运行

import java.io.*;
public class tongji {

public static void main(String[] args) //throws IOException
{
String str1,str2,str3,str4,str5;
int x=0,z=0,i=0,y=0;
int a[]=new int[5];
BufferedReader buf;
buf=new BufferedReader(new InputStreamReader(System.in));
System.out.print("输入成绩:");
str1=buf.readLine();
a[0]=Integer.parseInt(str1);
System.out.print("输入成绩:");
str2=buf.readLine();
a[1]=Integer.parseInt(str2);
System.out.print("输入成绩:");
str3=buf.readLine();
a[2]=Integer.parseInt(str3);
System.out.print("输入成绩:");
str4=buf.readLine();
a[3]=Integer.parseInt(str4);
System.out.print("输入成绩:");
str5=buf.readLine();
a[4]=Integer.parseInt(str5);
while(i<5)
{
if (a[i]<0 || a[i]>100)
System.out.print("输入错误!");
if (a[i]<60)
x=x+1;
if (a[i]>=60 && a[i]<=75)
y=y+1;
if (a[i]>75)
z=z+1;
i++;
}
System.out.println("A="+z);
System.out.println("B="+y);
System.out.println("C="+x);
}


}




SWT Designer v1.2.3 Released!

话题树型展开
人气 标题 作者 字数 发贴时间
7295 为什么不运行? huzi01245 2367 2007-03-27 20:21
5935 Re:为什么不运行? aaarong 212 2007-03-27 21:09

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