上海市计算机等级考试二级Java程序设计.docx

上传人:b****1 文档编号:3480716 上传时间:2023-05-05 格式:DOCX 页数:22 大小:612.16KB
下载 相关 举报
上海市计算机等级考试二级Java程序设计.docx_第1页
第1页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第2页
第2页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第3页
第3页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第4页
第4页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第5页
第5页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第6页
第6页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第7页
第7页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第8页
第8页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第9页
第9页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第10页
第10页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第11页
第11页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第12页
第12页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第13页
第13页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第14页
第14页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第15页
第15页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第16页
第16页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第17页
第17页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第18页
第18页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第19页
第19页 / 共22页
上海市计算机等级考试二级Java程序设计.docx_第20页
第20页 / 共22页
亲,该文档总共22页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

上海市计算机等级考试二级Java程序设计.docx

《上海市计算机等级考试二级Java程序设计.docx》由会员分享,可在线阅读,更多相关《上海市计算机等级考试二级Java程序设计.docx(22页珍藏版)》请在冰点文库上搜索。

上海市计算机等级考试二级Java程序设计.docx

上海市计算机等级考试二级Java程序设计

 

 

程序填空题

第1题。

程序实现青年歌手比赛的评分计算。

其计算方法是将十位评委的个人评分去掉其中的最高分和最低分,然后输出其余评委评分的平均值作为该歌手的最后得分。

运行该程序显示以下结果:

去掉一个最高分,去掉一个最低分,最后得分是:

请将程序补充完整。

publicclassContest{

publicstaticvoidmain(Stringarg[]){

inti,j;

(1);doublet

doublea[]={,,,,,,,,,};

doublesum=0,ave;

for(i=0;i<10;i++)

(2);"")

for(i=0;(3);i++)i<10

for(j=i+1;j<10;j++)

if(a[i]>a[j])

{t=a[j];a[j]=a[i];a[i]=t;}

for(i=1;i<;i++)

sum=sum+(4);a[i]

ave=sum/;

"\n去掉一个最高分"+(5)+a[]

","+"去掉一个最低分"+a[0]+","+"最后得分是:

"+ave);

}

}

 

 

程序填空题

第2题。

这是一个普通用户

货物:

电视机

价格:

数量:

2

总价:

这是一个会员用户

货物:

洗衣机

价格:

数量:

3

总价:

作为会员用户,享受九折优惠

总价:

请将程序补充完整。

abstractclassGoods{

(1)goods;String

floatprice;

double

(2);total

intnum;

publicabstractvoidgoods(String_goods,float_price,int_num);

}

classCommonextendsGoods{

publicvoid(3){showCommon()

"这是一个普通用户");

}

publicvoidgoods(String_goods,float_price,int_num){

goods=_goods;

price=_price;

num=_num;

total=_price*_num;

}

publicvoidshowBuy(){

"货物:

"+goods);

"价格:

"+price);

"数量:

"+num);

"总价:

"+total);

}

}

finalclassAssociatorextendsCommon{

publicvoidshowAssociator(){

"这是一个会员用户");}

publicvoidshowBuy(){

();

"作为会员用户,享受九折优惠");

"总价:

"+___(4)_____);total*

}

}

publicclassBuyGoods{

publicstaticvoidmain(Stringargs[]){

CommonAA=newCommon();

AssociatorBB=newAssociator();

();

("电视机",3800,2);

_______(5)________;()

("洗衣机",1980,3);

();

();

}

}

 

操作题

(一)程序调试题(本大题3小题,共8个错误,每改正一个分,共20分)

1.从"C:

\素材"中取出文件,该程序有三个错误。

正确的程序运行时应输出如下的结果:

按题中的要求调试修改该程序,并将结果(包括源文件、字节码文件)保存到C:

\KS目录中。

请务必在所修改的语句后加上注释语句:

;

publicclassExchange{

publicstaticvoidmain(Stringargs[])throwsIOException{

Stringhz_table[]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};

intnum,g,s;

Stringstr;

BufferedReaderbuf;

buf=newBufferedReader(newInputStreamReader);

"请输入整数:

");

str=();

num=(str);

if(num>=2)

"输入的数已超出范围");

else{

if()==2){

s=num%10;

g=num%10;

"你输入的数字是:

"

+hz_table[s]+"拾"+hz_table[g]);

}

else{

g=num;

"你输入的数字是:

"+hz_table[g]);

}

}

}

}

3.从"C:

\素材"中取出文件,该程序在Complex类声明代码模块中有三个错。

运行正确程序应产生如图所示的结果。

(该图示是用Eclipse运行的显示效果,仅作参考)。

请按题中的要求调试修改该程序,并将结果(包括源文件、字节码文件)保存到C:

\KS目录中。

请务必在所修改的语句后加上注释语句:

;

import.*;

publicclassComplex_exextendsApplet{

Complexx,y;

publicvoidinit(){

inta=7;

intb=2;

x=newComplex(a,b);

y=newComplex(a+3,b+4);

}

publicvoidpaint(Graphicsg){

("第一个复数:

"+(),10,50);

("第二个复数:

"+(),10,70);

}

}

classComplex{

intRealPart;

初始窗体图2.单击"出题"后的窗体

图3.单击"批改"后的窗体

(1)图4.单击"批改"后的窗体

(2)

import.*;

import.*;

import

publicclasslxextendsAppletimplementsActionListener{

privateLabell1;

privateLabell2;

privateLabell3;

privateLabell4;

privateTextFieldt1;

privateLabell5;

privateButtonb1;

privateButtonb2;

inta=0,b=0;C3.A4.B5.D6.B7.D8.B9.B10.B

11.A12.B13.C14.C15.A

程序填空题

1.1)【doublet】

2)【"")】

3)【i<10】【i<=9】【i<】【i<】

4)【a[i]】

5)【a[]】【a[9]】

2.1)【String】

2)【total】

3)【showCommon()】

4)【total*】【price*num*】

5)【()】

操作题

(一)程序调试题

1.

publicclassLoopEx{

publicvoidmain(String[]args){if(num>=2)classComplex{

intRealPart;publicclassAverage{

publicstaticvoidmain(String[]args){

int[]student={76,89,70,45,92,83,89,90,61};

floatavg=0;

avg=Avg(student);

("average="+avg);

}

staticfloatAvg(inta[]){

floata1=0;

for(inti=0;i<;i++){

a1=a1+a[i];

}

returna1/;

}

}

2.

import.*;

import.*;

import

publicclasslxextendsAppletimplementsActionListener{

privateLabell1;

privateLabell2;

privateLabell3;

privateLabell4;

privateTextFieldt1;

privateLabell5;

privateButtonb1;

privateButtonb2;

inta=0,b=0;

publicvoidinit(){

l1=newLabel("");

add(l1);

l2=newLabel("+");

add(l2);

l3=newLabel("");

add(l3);

l4=newLabel("=");

add(l4);

t1=newTextField("");

add(t1);

l5=newLabel("");

add(l5);

b1=newButton("出题");

add(b1);

b2=newButton("批改");

add(b2);

(this);

(this);

}

publicvoidactionPerformed(ActionEvente){

if()==b1){

a=(int)()*99+1);

b=(int)()*99+1);

(a+"");

(b+"");

("");

}

else

if().trim())==(a+b))

("正确!

");

else

("错误!

");

}

}

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > IT计算机 > 电脑基础知识

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2