Topic: 为什么不运行? |
Print this page |
1.为什么不运行? | Copy to clipboard |
Posted by: huzi01245 Posted on: 2007-03-27 20:21 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); } } |
2.Re:为什么不运行? [Re: huzi01245] | Copy to clipboard |
Posted by: aaarong Posted on: 2007-03-27 21:09 可以运行呀.......只要把public static void main(String[] args) //throws IOException 中的throws 前的注释标记符给删除就行了 { Please don't use BMP in the future! Your 286KB BMP has been converted to this 4KB GIF: } |
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 |