试题六 (共15 分)阅读以下说明和Java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。【 说明 】现需要统计某企业员工的月平均工资,即该企业本月发给员工的工资总和除以员工人数。 假设企业本月发给员工的工资总和为sumSalary,该企业的员工总数为employeeNumber,下面的程序代码计算该企业员工本月的平均工资,其中需要处理employNumber为0的情况。【 Java 代码 】import java.util.Scanner;public class JavaMain {static float average(float x, int y) throws Exception{if (y ==0 ) throw new Exception( (1) );return x/y;}static void caculate() throws Exception{float sumSalary;int employeeNumber;Scanner sc = new Scanner( (2) );try{System.out.println("请输入当月工资总和与员工数:");sumSalary = sc.nextFloat(); //从标准输入获得工资总和employeeNumber = sc.nextInt(); //从标准输入获得员工数float k = average(sumSalary,employeeNumber);System.out.println("平均工资:" + k);}(3) (Exception e){if(e.getMessage().equalsIgnoreCase("zero")){System.out.println("请重新输入当月工资总和与员工数:");sumSalary = sc.nextFloat();employeeNumber = sc.nextInt();float k = average(sumSalary,employeeNumber);System.out.println("平均工资:" + k);}}}public static void main(String[] args) {try {caculate();}(4) (Exception e){if ( e.getMessage().equalsIgnoreCase("zero"))System.out.println("程序未正确计算平均工资!" );}}}【问题1】程序运行时,若输入的员工工资总和为6000,员工数为5,则屏幕输出为:请输入当月工资总和与员工数:6000 5(5)【问题2】若程序运行时,第一次输入的员工工资总和为6000,员工数为0,第二次输入工工资总和为0,员工数为0,则屏幕输出为:请输入当月工资总和与员工数:6000 0(6)0 0(7)

试题六 (共15 分)

阅读以下说明和Java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。

【 说明 】

现需要统计某企业员工的月平均工资,即该企业本月发给员工的工资总和除以员工人数。 假设企业本月发给员工的工资总和为sumSalary,该企业的员工总数为employeeNumber,

下面的程序代码计算该企业员工本月的平均工资,其中需要处理employNumber为0的情况。

【 Java 代码 】

import java.util.Scanner;

public class JavaMain {

static float average(float x, int y) throws Exception{

if (y ==0 ) throw new Exception( (1) );

return x/y;

}

static void caculate() throws Exception{

float sumSalary;

int employeeNumber;

Scanner sc = new Scanner( (2) );

try{

System.out.println("请输入当月工资总和与员工数:");

sumSalary = sc.nextFloat(); //从标准输入获得工资总和

employeeNumber = sc.nextInt(); //从标准输入获得员工数

float k = average(sumSalary,employeeNumber);

System.out.println("平均工资:" + k);

}

(3) (Exception e){

if(e.getMessage().equalsIgnoreCase("zero")){

System.out.println("请重新输入当月工资总和与员工数:");

sumSalary = sc.nextFloat();

employeeNumber = sc.nextInt();

float k = average(sumSalary,employeeNumber);

System.out.println("平均工资:" + k);

}

}

}

public static void main(String[] args) {

try {

caculate();

}

(4) (Exception e){

if ( e.getMessage().equalsIgnoreCase("zero"))

System.out.println("程序未正确计算平均工资!" );

}

}

}

【问题1】

程序运行时,若输入的员工工资总和为6000,员工数为5,则屏幕输出为:

请输入当月工资总和与员工数:

6000 5

(5)

【问题2】

若程序运行时,第一次输入的员工工资总和为6000,员工数为0,第二次输入

工工资总和为0,员工数为0,则屏幕输出为:

请输入当月工资总和与员工数:

6000 0

(6)

0 0

(7)


相关考题:

●试题四阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】函数QuickSort是在一维数组A[n]上进行快速排序的递归算法。【函数】void QuickSort(int A[],int s,int t){int i=s,j=t+1,temp;int x=A[s];do{do i++;while (1) ;do j--;while(A[j]x);if(ij){temp=A[i]; (2) ; (3) ;}}while(ij);A[a]=A[j];A[j]=x;if(si-1) (4) ;if(j+1t) (5) ;}

试题六(共15分)阅读下列说明和Java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。【说明】某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰( Decorator)模式实现打印发票的功能,得到如图6-1所示的类图。【java代码】class invoice{public void printInvoice(){:System.out.println ( This is the content of the invoice!);}}class Decorator : extends Invoice {protected Invoice ticket;public Decorator(lnvoice t){ticket = t;}public void printinvoice(){if(ticket != NULL)(1);}}class FootDecorator extends Decorator{public FootDecorator(lnvoice t){super(t);}public void printinvoice (){Systent.out.println( This is the header of the invoice! );(2) ;}}class FootDecorator extends Decorator {public FootDecorator(invoice t):{super(t);}public void printlnvoice(){(3) ;Systent.out.println( This is the header of the invoice! );}}Class test {public static void main(string[] args){Invoice t =new invioce();Invoice ticket;Ticket= (4) ;Ticket. Printinvoice();Systent.out.println(“--------------“)Ticket= (5) ;Ticket. Printinvoice();}}程序的输出结果为:This is the header of the invoice!This is the content of the invoice!This is the footnote of the invoice!----------------------------This is the header of the invoice!This is the footnote of the invoice!

●试题二阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】该程序运行后,输出下面的数字金字塔【程序】includestdio.hmain (){char max,next;int i;for(max=′1′;max=′9′;max++){for(i=1;i=20- (1) ;++i)printf(" ");for(next= (2) ;next= (3) ;next++)printf("%c",next);for(next= (4) ;next= (5) ;next--)printf("%c",next);printf("\n");}}

试题三(共 15 分)阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。

(a)智能网概念模型中分布功能平面模型如下图所示,请根据此图将应填入(n)处的 字句写在答题纸的对应栏内。

阅读下列说明和C++-代码,将应填入(n)处的字句写在答题纸的对应栏内。 【说明】 某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰(Decorator)模式实现打印发票的功能,得到如图5-1所示的类图。【C++代码】 #include using namespace std; class invoice{ public: (1){ cout

阅读下列说明和C++代码,回答问题,将解答填入答题纸的对应栏内。【说明】某航空公司的会员积分系统将其会员划分为:普卡 (Basic)、银卡(Silver)和金卡 (Gold) 三个等级。非会员 (NonMember) 可以申请成为普卡会员。会员的等级根据其一年内累积 的里程数进行调整。描述会员等级调整的状态图如图 5-1 所示。现采用状态 (State) 模式实现上述场景,得到如图 5-2 所示的类图。【问题1】(15分)阅读上述说明和C++代码,将应填入 (n) 处的字句写在答题纸的对应栏内。

阅读下列说明和 Java 代码,将应填入(n)处的字句写在答题纸的对应栏内。 【说明】 某软件公司欲开发一款汽车竞速类游戏,需要模拟长轮胎和短轮胎急刹车时在路面上 留 下的不同痕迹,并考虑后续能模拟更多种轮胎急刹车时的痕迹。现采用策略(Strategy) 设 计模式来实现该需求,所设计的类图如图 5-1 所示。

阅读下列说明和Java代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】 某文件管理系统中定义了类OfficeDoc和DocExplorer,当类OfficeDoc发生变化时,类DocExplorer的所有对象都要更新其自身的状态,现采用观察者(Observer)设计模式来实现该需求,所设计的类图如图6-1所示。

阅读下列说明和?C++代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】阅读下列说明和?Java代码,将应填入?(n)?处的字句写在答题纸的对应栏内。【说明】某快餐厅主要制作并出售儿童套餐,一般包括主餐(各类比萨)、饮料和玩具,其餐品种类可能不同,但其制作过程相同。前台服务员?(Waiter)?调度厨师制作套餐。现采用生成器?(Builder)?模式实现制作过程,得到如图?6-1?所示的类图。