第六届全国信息技术应用水平大赛Java组复赛B卷试题答案
来源:互联网 发布:淘宝司法拍卖靠谱吗 编辑:程序博客网 时间:2024/04/28 15:27
1、 九九乘法口诀表是学习算数乘法的基础,用一个for循环编程实现并显示九九乘法口诀表,程序运行显示结果如下所示。(25分)
1*1=1
1*2=2 2*2=4
1*3=3 2*3=6 3*3=9
1*4=4 2*4=8 3*4=12 4*4=16
1*5=5 2*5=10 3*5=15 4*5=20 5*5=25
1*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36
1*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49
1*8=8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64
1*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81
2、 编写一个Java应用程序,定义一个表示学生的类Student,包括属性:学号、班级、姓名、性别、年龄,以及方法:获得学号、获得班级号、获得年龄、设置年龄。创建这个类的对象并验证各个方法。(20分)
3、 字符串是一串包含一定序列的字符数据,Java的String类型的数据是具有不变性的,请编程实现某一个指定字符串的反序输出。(25分)
要求如下:
(1)不能使用StringBuffer的reverse()方法;
(2)指定字符串为“第六届全国信息技术应用水平大赛”。
4、 编写一个Java应用程序,程序运行后,要求到指定的文件夹(比如d:\work目录)查找后缀为java的文件,取出并保存到d:\test目录下。(30分)
附加题:
5、 先设计一个类:Student,包含3个成员变量:学号、姓名、英语成绩,并实现赋成员变量初值的构造方法。然后编写程序,使用Hashtable()创建一个散列表,存放Student对象,每个Student对象用该对象的学号作为关键字,检索学号为199902的元素并显示,然后遍历当前散列表并显示所有元素,结果如下图所示。(20分)
6、 编程实现输入格式为“yyyy-mm-dd”的字符串,获得一个给定的日期,计算此日期的下一天的日期并输出,程序验证时候,要考虑任意日期是月底、年底、闰年的情况。(30分)
package Six;
public class B1 {
public static void main(String[] args) {
for (int i = 1, j = 1; i <= 9; j++) {
System.out.print(j + "x" + i + "=" + j * i + "\t");
if (j == i) {
i++;
j = 0;
System.out.println();
}
}
}
}
T2:
package ITAT;
public class SixthB2 {
public static void main(String[] args) {
Student3 student = new Student3(1001,2,"林郭隆",22);
System.out.println("获得学号: "+student.getNumber());
System.out.println("获得班级号: "+student.getBanJi());
System.out.println("获得年龄: "+student.getAge());
student.setAge(18);
System.out.println("设置后的年龄: "+student.getAge());
}
}
class Student3{
private int number;
private int banJi;
private String name;
private int age;
public Student3(int number, int banJi, String name, int age) {
super();
this.number = number;
this.banJi = banJi;
this.name = name;
this.age = age;
}
public int getNumber(){
return number;
}
public int getBanJi(){
return banJi;
}
public int getAge(){
return age;
}
public void setAge(int age){
this.age = age;
}
}
T3:
package Six;
public class B3 {
public static void main(String[]args){
String str="第六届信息技术大赛";
for(int i=str.length()-1;i>=0;i--)
System.out.print(str.charAt(i));
}
}
T4:
package Six;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class B4 {
public static void main(String[] args) throws IOException {
File from = new File("D:" + File.separator + "work");
File to = new File("D:" + File.separator + "test");
byte[] b = new byte[1024];
InputStream in;
OutputStream out;
File[] files = from.listFiles();
if (files.length != 0) {
for (File file : files) {
if (file.getName().endsWith(".java")) {
in = new FileInputStream(file);
out = new FileOutputStream(new File(to, file.getName()));
while (in.read(b) != -1) {
out.write(b);
}
System.out.println("成功复制文件" + file.getName() + "到"
+ to.getName() + "目录");
in.close();
out.close();
}
}
} else {
System.out.println(from.getName() + "目录下没有文件");
}
}
}
T5:
package Six;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class B5 {
public static void main(String[] args) {
Student student1 = new Student(101344, "郑永亮", 99);
Student student2 = new Student(101345, "张三", 89);
Student student3 = new Student(101346, "李四亮", 79);
Student student4 = new Student(101347, "王二亮", 69);
Student student5 = new Student(101348, "刘亮", 9);
Hashtable<Integer, Student> table = new Hashtable<Integer, Student>();
table.put(student1.number, student1);
table.put(student2.number, student2);
table.put(student3.number, student3);
table.put(student4.number, student4);
table.put(student5.number, student5);
Set<Map.Entry<Integer, Student>> set = table.entrySet();
Iterator<Map.Entry<Integer, Student>> it = set.iterator();
while (it.hasNext()) {
Map.Entry<Integer, Student> entry = it.next();
System.out.println(entry.getValue());
}
}
}
class Student {
int number;
String name;
int score;
public Student(int number, String name, int score) {
this.name = name;
this.number = number;
this.score = score;
}
public String toString() {
return number + "\t" + name + "\t" + score;
}
}
T6:
package Six;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
class B6 {
public static void main(String[] args) throws ParseException {
Scanner sc = new Scanner(System.in);
System.out.print("请输入一个yyyy-mm-dd格式的日期:");
String str = sc.nextLine();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = sdf.parse(str);
date.setTime(date.getTime() + 24 * 60 * 60 * 1000);
System.out.println("明天的日期是:" + sdf.format(date));
}
}
- 第六届全国信息技术应用水平大赛Java组复赛B卷试题答案
- 第六届全国信息技术应用水平大赛Java组复赛A卷试题答案
- 第四届全国ITAT教育工程就业技能大赛Java组复赛B卷试题答案
- 第五届全国ITAT教育工程就业技能大赛Java组复赛B卷试题答案
- 第五届全国ITAT教育工程就业技能大赛Java组复赛A卷试题答案
- 第七届信息技术应用大赛Java组复赛A卷参考答案
- 第六届全国ITAT教育工程就业技能大赛复赛试题 Java程序设计(B卷)答案
- 第五届全国信息水平设计大赛C语言复赛B卷答案
- 第六届全国信息技术应用水平大赛比赛说明(电子系统设及团体比赛)(
- 第七届信息技术应用水平大赛 复赛杂感
- 第三届信息技术大赛Java组B卷答案
- 第五届全国信息技术应用水平大赛预赛试题
- 第七届全国信息技术应用水平大赛模拟题 JAVA程序设计
- 第四届全国ITAT教育工程就业技能大赛复赛试题Java组A卷答案
- 第五届全国ITAT教育工程就业技能大赛复赛试题 Java程序设计(B卷)答案
- 第三届全国ITAT教育工程就业技能大赛复赛试题 Java程序设计(B卷)答案
- 全国信息技术应用水平大赛历届经典试题解析
- 全国信息水平第六届C语言设计竞赛复赛A卷答案
- 虚拟机下安装Gentoo
- C++愤恨者札记7——函数适配器
- poj 1698 最大流
- android 裁剪图片大小 控制图片尺寸 .
- 一个清华大学学生几天猎头生活的感想
- 第六届全国信息技术应用水平大赛Java组复赛B卷试题答案
- java-抓取指定URL网页的内容
- Linux命令 关机/重启
- c语言结构体struct
- 标称电阻
- IO电平标准
- 常用贴片封装
- 续行符
- [ubuntu12.04] sudo 不验证设置