oc.operate(asp); oc.operate(aes); } }
评分标准:
1、写出能完成题目要求功能的、可正常运行的java程序,给满分,否则0分
~~~b
编写程序求解1!+2!+3!+??+10!的值,并在屏幕上输出,要求用递归的方法求一个数的阶乘。 ~
参考程序如下: public class 阶乘和 {
public class 阶乘和 { public long f(int n){
}
if(n==1)
return 1; else
return n*f(n-1);
public static void main(String[] args) {
阶乘和 m=new 阶乘和(); long sum=0;
}
for(int i=1;i<11;i++){ }
sum+=m.f(i);
System.out.println(\的阶乘和为:\+sum); }
评分标准:
1、写出能完成题目要求功能的、可正常运行的java程序,给满分,否则0分。
~~~b
有四本书,书名分别为“Java2核心技术”,\应用程序设计基础教程\案例开发大全\大学教程\。要求编写程序,将这四本书的名字每隔一秒钟动态的输出在屏幕上。 ~
参考程序如下:
public class 动态输出 { public static void main(String[] args) { String[] s={\核心技术\应用程序设计基础教程\案例开发大全\
大学教程\ Thread t=new MyThread4(s); t.start(); } }
class MyThread4 extends Thread{ private String[] s; public MyThread4(String[] s){ this.s=s; } public void run(){ for(int i=0;i 评分标准: 1、写出能完成题目要求功能的、可正常运行的java程序,给满分,否则0分。 ~~~b 当用户输入的数据中有小写的字母时,自动转换为大写字母。编写程序完成该功能。 ~ 参考程序如下: import java.io.*; import java.util.Scanner; public class 小写转换大写 { public static void main(String[] args) { } } Scanner sc=new Scanner(System.in); String s; System.out.println(\请输入一个字符串\); s=sc.next(); String s2=s.toUpperCase(); System.out.println(s2); 评分标准: 1、写出能完成题目要求功能的、可正常运行的java程序,给满分,否则0分 ~~~b 利用循环控制语句,输出如下所示数字塔。 1 1 22 22 333 333 4444 4444 55555 55555 666666 666666 7777777 7777777 88888888 88888888 999999999999999999 ~ 参考程序如下: public class 数字塔 { public static void main(String[] args) { for(int i=1;i<=9;i++){ for(int k=1;k<=i;k++) System.out.print(i); for(int j=2*(9-i);j>=1;j--) System.out.print(\ for(int k=1;k<=i;k++) System.out.print(i); System.out.println(); } } } 评分标准: 1、写出能完成题目要求功能的、可正常运行的java程序,给满分,否则0分 ~~~b 双色球福利彩票的摇奖规则是从号码为1-33的红色球中随机选取六个,从号码为1-16的蓝色球中随机选取一个组成号码。编写程序,模拟双色球福利彩票开奖号码生成过程。 ~ 参考程序如下: public class 双色球模拟 { public static void main(String[] args) { String s=\; int red=0; int blue=0; for(int i=0;i<6;i++){ } red=(int)(Math.random()*33)+1; s+=red+\; } blue=(int)(Math.random()*16)+1; s+=blue; System.out.println(\本次双色球福利彩票开奖号码为:\+s); } 评分标准: 1、写出能完成题目要求功能的、可正常运行的java程序,给满分,否则0分 ~~~b 编写程序,要求用递归的方法求解表达式1×2+2×3+3×4+4×5+5×6+6×7+7×8+8×9+9×10的值,并将结果按格式1×2+2×3+3×4+4×5+5×6+6×7+7×8+8×9+9×10=330形式输出。 ~ 参考程序如下: public class 表达式值 { //递归方法 public static int fn(int n){ int result; if(n==1) result=2; else result=fn(n-1)+2*n; return result; } public static void main(String[] args) { int sum=0,i; for(i=1;i<9;i++){ System.out.print(i+\ sum+=fn(i); } System.out.print(i+\ } } 评分标准: 1、写出能完成题目要求功能的、可正常运行的java程序,给满分,否则0分 ~~~b 编写程序,利用循环控制语句输出如下数字金字塔图形。 1 2 2 2 3 3 3 3 3 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 ~ 参考程序如下: public class 金字塔 { public static void main(String[] args) { int row=9; for(int i=1;i<=row;i++){ for(int j=row;j>=i;j--){ System.out.print(\ \ } for(int k=i;k>=1;k--){ System.out.print(i<10?\ } for(int l=2;l<=i;l++){ System.out.print(i<10?\ } System.out.println(); } } } 评分标准: 1、写出能完成题目要求功能的、可正常运行的java程序,给满分,否则0分 ~~~c 编写程序,利用线程模拟一段时间内(3分钟)交通信号灯的运行状况,红灯亮10秒,绿灯亮30秒,黄灯亮3秒。 ~ 参考程序如下: /** * 显示一个时段内信号灯的运行状况。 */ class MyThread3 implements Runnable { private String[] s; public MyThread3(String[] s){ this.s=s; } public void run(){ int count=0; long startTime=System.currentTimeMillis(); long endTime=System.currentTimeMillis();