程序改错 共10题
程序代码中,“**********FOUND**********”语句的下一行有错误。1./*------------------------ 【程序改错】
-------------------------- 题目:从键盘上输入一个字符,判断该字符是数字字符、英文字符
还是其他字符
------------------------*/ import java.io.*; public cla Prog1 { public static void main(String args[]) throws IOException { /***********FOUND***********/ boolean c; 请在此处填写答案:_______________________________ /***********FOUND***********/ c=System.in.read(); 请在此处填写答案:_______________________________ if (c>=\'0\'&&c=\'A\'&&c=\'a\'&&c
/*------------------------ 【程序改错】
-------------------------- 题目:计算1到100的整数和值
------------------------*/ public cla Prog1 { /***********FOUND***********/ public static void main (args[]) 请在此处填写答案:_______________________________ { /***********FOUND***********/ int n=100,sum=1; 请在此处填写答案:_______________________________ while(n>0)
{ sum+=n; /***********FOUND***********/ n++; 请在此处填写答案:_______________________________ } /***********FOUND***********/ System.println(\"Sum is \"+sum); 请在此处填写答案:_______________________________ } } 3.
/*------------------------ 【程序改错】
-------------------------- 题目:从键盘上输入一个正整数,计算该数的各位数字之和
------------------------*/ import java.io.*; /***********FOUND***********/ public Prog1 请在此处填写答案:_______________________________ { public static void main(String args[]) throws IOException { int m,s; BufferedReader buf; buf=new BufferedReader(new InputStreamReader(System.in)); System.out.print(\"请输入一个自然数:\"); m=Integer.parseInt(buf.readLine()); /***********FOUND***********/ m=0; 请在此处填写答案:_______________________________ while(m!=0) { /***********FOUND***********/ s=s+m/10; 请在此处填写答案:_______________________________ /***********FOUND***********/ m=m%10; 请在此处填写答案:_______________________________ } System.out.print(\"其各位数字之和为:\"+s); } } 4.
/*------------------------ 【程序改错】
-------------------------- 题目:求1到100的偶数之和,奇数之积
------------------------*/
public cla Prog1 { public static void main(String args[]) { /***********FOUND***********/
int i,j,sum=1; 请在此处填写答案:_______________________________ /***********FOUND***********/ int product=1; 请在此处填写答案:_______________________________ for(i=1;i
-------------------------- 题目:计算并输出100以内最大的10个能被3或7整除的自然数之和 ------------------------*/ public cla Prog1 { public static void main(String args[]) { int k,s=0,mc=0; /***********FOUND***********/ for (k=500;k>0;k++) 请在此处填写答案:_______________________________ { /***********FOUND***********/ if (k%3 == 0 && k%7==0) 请在此处填写答案:_______________________________ { /***********FOUND***********/ s=k; 请在此处填写答案:_______________________________
mc++; } /***********FOUND***********/ if (mc=10) 请在此处填写答案:_______________________________ break; } System.out.println(\"Sum is \"+s); } }
6. /*------------------------ 【程序改错】
-------------------------- 题目:完成程序的编写,运行结果显示如下: 1 2 3 4 5 6 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1 ------------------------*/ public cla Java_2 { public static void main(String[] args) { /***********FOUND***********/ int[] aTriangle = new int[6][]; 请在此处填写答案:_______________________________ int i = 0; int j = 6; int k = 0; /***********FOUND***********/ for ( i = 0; i
}
7.
/*------------------------ 【程序改错】
-------------------------- 题目:该程序的功能是打印如下所示图形: * *** ***** ******* ********* ------------------------*/ public cla Java_1 { public static void main(String[] args) { /***********FOUND***********/ for (int i=1;i
8.
/*------------------------ 【程序改错】
-------------------------- 题目:根据学生的考试的百分制成绩得出分数等级。
(90~100为A级,80~89为B级,70~79为C级,60~69为D级, 60分以下为E级) ------------------------*/ import java.io.*; public cla Prog1 { public static void main(String args[]) throws IOException { int grade; /*****************FOUND*****************/ boolean str;
请在此处填写答案:_______________________________ BufferedReader buf; buf=new BufferedReader(new InputStreamReader(System.in)); System.out.print(\"请输入考试成绩:\"); str=buf.readLine(); /*****************FOUND*****************/ grade=Int.parseInt(str); 请在此处填写答案:_______________________________ System.out.print(\"对应的级别为:\"); /*****************FOUND*****************/ if (grade>90) 请在此处填写答案:_______________________________ System.out.println(\"A\"); else if (grade>=80) System.out.println(\"B\"); else if (grade>=70) System.out.println(\"C\"); else if (grade>=60) System.out.println(\"D\"); /*****************FOUND*****************/ otherwise 请在此处填写答案:_______________________________ System.out.println(\"E\"); } } 9. /*------------------------ 【程序改错】
-------------------------- 题目:该程序功能是,从键盘输入5个整数,输出其中最大值。
例如:从键盘输入 10 30 50 20 40 则屏幕显示
输入的最大值是 50 ------------------------*/ import java.io.*; public cla Java_1 { /***********FOUND***********/ public static void main(String args) throws IOException { 请在此处填写答案:_______________________________ InputStreamReader ir; BufferedReader in; int max, x; String data;
max = 0; ir = new InputStreamReader(System.in); in = new BufferedReader(ir); System.out.println(\"请输入5个正整数:\"); /***********FOUND***********/ for (int i = 1; i
10. /*------------------------ 【程序改错】
-------------------------- 题目:从键盘上接受用户输入的10个整数,并输出这10个整数的
最大值和最小值
------------------------*/ import java.io.* ; public cla Prog1 { public static void main(String args[ ]) throws IOException { int i, n=10, max, min,temp,sum=0; BufferedReader buf; buf=new BufferedReader(new InputStreamReader(System.in)); /***********FOUND***********/ max=min==Integer.parseInt(buf.readLine()); 请在此处填写答案:_______________________________ /***********FOUND***********/ for ( i=1; i max ) /***********FOUND***********/ temp=max; 请在此处填写答案:_______________________________ if (temp
/***********FOUND***********/ temp=min; 请在此处填写答案:_______________________________ } System.out.println(\"max=\"+max+\"\\nmin=\"+min); } }