阅读以下说明和Java程序,将应填入(n)处的字句写在对应栏内。[说明]下面程序输出一个矩形面积,以及矩形区域上的假想的作物产量。[Java程序]public class MainJava {public static void main(String[] args){Lot_size small=new Lot_size();Lot_size medium=new Lot_size();small.set(5,5,5,25);medium.set(10,10,10,50);System.out.println("For a small lot of area"+small.get_area()+"\n");System.out.println("the actual crops are $"+small.get_data2()+"\n");System.out.println("and ideal crops are $"+small.get data()+"\n");System.out.println("For a medium lot of area"+medium.get_area()+“\n”);System.out.println("the actual crops are $"+medium.get_data2()+"\n");System.out.println ("and ideal crops are $"+medium.get_data()+"\n");}}class Crop_assessment{private int actual_crop;private int ideal_crop;public void set(int in_actual,int in ideal){actual_crop=in_actual;ideal_crop=in_ideal;}public int get_actual_crop(){return (1) ;}public int get_ideal_crop()(return (2) ;}}class Lot_size{private int length;private int width;private Crop_assessment crop= (3) ;public void set(int 1,int W,int a,int i){length=1;width=W;crop.set(a,i);}public int get_area(){return length*width;}public int get_data()freturn (4) ;}public int get_data2()(return (5) ;}}

阅读以下说明和Java程序,将应填入(n)处的字句写在对应栏内。

[说明]

下面程序输出一个矩形面积,以及矩形区域上的假想的作物产量。

[Java程序]

public class MainJava {

public static void main(String[] args){

Lot_size small=new Lot_size();

Lot_size medium=new Lot_size();

small.set(5,5,5,25);

medium.set(10,10,10,50);

System.out.println("For a small lot of area"

+small.get_area()+"\n");

System.out.println("the actual crops are $"

+small.get_data2()+"\n");

System.out.println("and ideal crops are $"

+small.get data()+"\n");

System.out.println("For a medium lot of area"

+medium.get_area()+“\n”);

System.out.println("the actual crops are $"

+medium.get_data2()+"\n");

System.out.println ("and ideal crops are $"

+medium.get_data()+"\n");

}

}

class Crop_assessment{

private int actual_crop;

private int ideal_crop;

public void set(int in_actual,int in ideal){

actual_crop=in_actual;

ideal_crop=in_ideal;

}

public int get_actual_crop(){return (1) ;}

public int get_ideal_crop()(return (2) ;}

}

class Lot_size{

private int length;

private int width;

private Crop_assessment crop= (3) ;

public void set(int 1,int W,int a,int i){

length=1;

width=W;

crop.set(a,i);

}

public int get_area(){return length*width;}

public int get_data()freturn (4) ;}

public int get_data2()(return (5) ;}

}


相关考题:

阅读下列程序说明和C代码,把应填入其中n处的字句写在对应栏内。【说明】下面的程序能够计算不同图形的面积。程序中把每个图形的数据定义成结构类型,利用共同体类型描述2种图形的数据。程序根据输入参数代表的图形类型,求出图形的面积并输出。【程序】struct Circle{float x,y; /*圆心位置*/float r; /*圆半径*/};struct Rectangle{float width; /*矩形宽*/float length; /*矩形长*/};union shape{struct Circle circle;/*圆数据结构*/struct Rectangle rectangle;/*矩形数据结构*/};main(){union shape a;float area;int i;printf(“input number: 1circle,2rectangle,3 end\n”);scanf("%d",i);while (1) /*循环接收输入,并计算输出*/{switch(i){case 1:printf(“input radius:\n”);scanf(“%f”, (2);/*共同体类型变量接收输入*/area=3.1415926* (3);printf(“the area of circle=%f\n”,area);break;case 2:printf(“input width and length :\n”);seanf(“%f,%f”, (4);/*共同体类型变量接收输入*/。area=(5);printf(“the area of rectangle=%f\n”,area);break;}printf(“input number:1 circle,2 rectangle,3 end\n”);scanf(“%d”,i);}}

阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。[说明]编写一个字符界面的Java Application 程序,接受用户输入的10个整数,并输出这10个整数的最大值和最小值。[Java 代码]import java. io.* ;public class abc{public static void main ((1)){int i, n=10, max=0, min=0, temp=0;try {BufferedReader br = new BufferedReader (new InputStreamReader ( System.in ) );max = min =Integer. parselnt ( br. readLine ( ) );}. (2) ( IOExccption e ) {} ;for ( i=2 ; i<=n ; i++ ) {try {BufferedReader br = new (3) (new InputStreamReader ( System. in ) );temp =(4) ( br. readLine ( ));if (temp>max ) max=temp;if (temp<min) (5)} catch (IOException e ) {};}System.out.println ( "max="+max+"\nmin="+min );}}

阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。【说明】StringEditor类的功能是:已知一个字符串,返回将字符串中的非字母字符都删除后的字符串。public (1) {public static String removeNonLetters( (2) ){StringBuffer aBuffer=(3);char aCharacter;for(int i=0; i<original.length();i++){aCharacter=(4);if(Character.isLetter(aCharacter))aBuffer.append( (5) );}return new String(aBuffer);}}public class StringEditorTester{public static void main(String args[]){String riginal="Hi!, My Name is Mark, 234I think you are my classmate?!!";System.out.println(StringEditor.removeNonLetters(original));}}

阅读以下说明、Java代码和HTML文档,将应填入(n)处的字句写在答题纸的对应栏内。【说明】当用户启动html浏览器并首次打开下面的HTML文档时,Java Applet小程序在显示面板上显示字符串“Welcome!”;当html页面被其他窗口遮挡后再次显示时,小程序在显示面板上显示“Welcome back!”。【Java代码】import javA.awt.*;import javA.applet;public class HelloApplet extends (1) {public void paim((2)){g.drawString(message,10,20);message="welcome back!”;}public void (3) (){message="Welcome!”;}private (4) message;}【HTML文档】<html><head><title>HTML Test HelloApplet Page</title></head><body>Test HelloApplet小程序<br><appletcodebase="."code="(5) "name="TestApplet"width="400"height="300"></applet></body></html>

阅读以下说明和Java码,将应填入(n)处的字名写在对应栏内。[说明] 编写一个字符界面的Java Application 程序,接受用户输入的10个整数,并输出这10个整数的最大值和最小值。import java. io. * ;public class abc{public static void main(String args [ ] ){ int i, n = 10 , max = 0 , min = 0 , temp = 0;try {BufferedReader br = new BufferedReader(new InputStreamReader( System. in) );(1));} catch ( IOException e ) { } ;for(i = 2 ;i <= n; i ++ ) {try {BufferedReader br = new BufferedReader(new InputStreamReader (System. in) );temp = Integer. parselnt(br. readLine( ) );if ( temp > max ) (2)if (temp < min) (3)} catch ( IOExeeption e ) { } ;System. out. println( "max =" + max + "\nmin =" + min);}}

阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。【说明】已知头指针分别为La和lb的有序单链表,其数据元素都是按值非递减排列。现要归并La和Lb得到单链表Lc,使得Lc中的元素按值非递减排列。程序流程图如下所示:

阅读以下说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。【说明】以下程序为求行列式X(5,5)的值S。【Visual Basic代码】Private Function col ( byval x ( 5,5 ) as integer ) as longdim fesult as longdim temp as longdim I as integerdim j as integerdim k as imegerresult = 0for I = to 5(1)for j = 1 to 5if I+j>6 thenk= ( 1+j ) mod 5elsek=1endiftemp=temp*x ( k,j )(2)result=(3)(4)(5)End function

阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。[说明]设学生某次考试的成绩按学号顺序逐行存放于某文件中,文件以单行句点“.”为结束符。下面的流程图读取该文件,统计出全部成绩中的最高分max和最低分min。

阅读以下说明、Java代码和HTML文档,将应填入(n)处的字句写在对应栏内。【说明】当用户启动html浏览器并首次打开下面的html文档时,Java Applet小程序在显示面板上显示字符串“欢迎您!”;当html页面被其他窗口遮挡后再次显示时,小程序在显示面板上显示“欢迎您回来!”[Java代码]import java.awt.*;import java.applet.*;public class HelloApplet extends (1) {public void paint( (2) ){g.drawString(message,10,20);message="欢迎您回来!";}public void (3) (){message="欢迎您!";}private (4) message;}[HTML文档]<html><head><title>HTML Test HelloApplet Page</title></head><body>Test HenoApplet 小程序<br><appletcodebase="."code="(5)"name="TestApplet"width="400"height="300"></applet></body></html>

阅读以下说明、Java代码,将应填入(n)处的字句写在对应栏内。【说明】本程序输出10000之内的所有完全数。完全数是指等于其所有因子和(包括1,但不包括这个数本身)的数。例如:6=1×2×3,6=1+2+3,则6是一个完全数。【程序】public class PerfectNum{Public static void main(String args[]){int count=1;for(int i=1; i<10000; i++){int y=0;for(int j=1; j<i; j++)if((1))y=(2)if((3)){System.out.print( (4) +String.valueOf('\t'));(5)If(count%3==0)System.out.printin();}}}

阅读以下说明,以及用C++在开发过程中所编写的程序代码,将应填入(n)处的字句写在对应栏内。【说明】在下面函数横线处填上适当的字句,使其输出结果为:构造函数.构造函数.1,25,6析构函数析构函数.【C++代码】include "iostream.h"class AA{ public;AA(int i,int j){A=i; B=j;cout<<"构造函数.\n";}~AA(){(1);}void print();private:int A, B;};void AA∷print(){cout<<A<<","<<B<<endl;}void main(){AA *a1, *a2;(2)=new AA(1, 2);a2=new AA(5, 6);(3);a2->print();(4) a1;(5) a2;}

阅读以下说明和Java程序,将应填入(n)处的字句写在对应栏内。[说明]下面程序实现十进制向其它进制的转换。[Java程序]ClasS Node{int data;Node next;}class Transform{private Node top;public void print(){Node p;while(top!=null){P=top;if(P.data>9)System.out.print((char)(P.data+55));elseSystem.out.print(p.data);top=p.next;}}public void Trans(int d,int i){//d为数字;i为进制int m;(1) n=false;Node p;while(d>0){(2);d=d/i;p=new Node();if( (3) ){p.data=m;(4);top=P;n=true;}else{p.data=m;(5);top=P;}}}}

阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。【说明】下面程序完成从键盘读入一个字符串,然后采用parseInt方法将其转换为一个相应的整数。import java.io.*;public class testThrows{public static (1) readString() (2) IOException{int ch;String r="";boolean done=false;while((3)){ch=System.in.read();if(ch<0 || ch=0xd) //处理回车符中第一个符号done=true;elser=r+(char)ch;}return r;}public static void main(Stling args[]){String str;(4) {str=readString();} (5) (IOException e){System.out.println("error");return;}System.out.println("input integer: "+Integer.parselnt(str));}}

阅读以下说明和Java以及HTML代码,将应填入(n)处的字句写在对应栏内。[说明]编写一个Applet程序,接受HTML文件传递的整数参数,根据该参数指定Applet中文本框的长度。编写对应的HTML文件运行这个Applet。[Java 代码]import java. applet.*;import java. awt.*;public class chuangdics extends (1){TextField tf=new TextField ();int tfLength=0;public void init(){try{tfLength=Integer. parseInt( (2) ("length"));tf. setColumns (tfLength);add (tf);}catch (NumberFormatException nfe){tf. (3) ("HTML 文件传人的参数格式错误。");add(tf);}}}[HTML 代码]<html><head><title>(4)</title></head><body><hr><applet code=chuangdics width=700 height=150><param name=length value=20>(5)<hr></body></htmI>

阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写在对应栏内。【说明】阅读下面几段C++程序回答相应问题。比较下面两段程序的优缺点。①for (i=0; i<N; i++ ){if (condition)//DoSomething…else//DoOtherthing…}②if (condition) {for (i =0; i<N; i++ )//DoSomething}else {for (i=0; i <N; i++ )//DoOtherthing…}

阅读以下说明和JAVA 2代码,将应填入(n)处的字句写在对应栏内。[说明]以下程序为类类型的变量应用实例,通过异常处理检验了类CCircle的变量的合法性,即参数半径应为非负值。仔细阅读代码和相关注释,将程序补充完整。[JAVA代码]//定义自己的异常类class CCircleException extends Exception{}// 定义类 CCircleclass CCircle{private double radius;public void setRadius ( double r ) (1){if ( r<0 ) {(2)}else(3)}Public void show ( ) {System. out. println ( "area="+3.14*radius*radius );}}public class ciusample{public static void main ( String args[] ){CCircle cir=new CCircle( );(4) {cir. setRadius ( -2.0 )}(5){System. out. println ( e+" throwed" ) ;}cir. show( ) ;}}

阅读下列程序说明和C程序,将应填入(n)处的字句写在对应栏内。[函数2.1说明]下面程序的功能是计算x和y的最小公倍数。[函数2.1]main(){ int m,n,d,r;seanf("%d %d",m,n);if(m<n) {r=m;m=n;n=r;}(1);while (d%n! =0) (2);printf("%d\n",d);}[函数2.2说明]下述程序接收键盘输入,直到句点“.”时结束。输入的字符被原样输出,但连续的空格输入将转换成一个空格。[函数2.2]include <stdio.h>main(){ char c,preChar='\0';c = getchar();while(c! = '.'){if((3)) putchar(c);else if(preChar! =' ') putchar(c);(4);c=(5);}}

阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。[说明]下面的流程图用于计算一个英文句子中最长单词的长度(即单词中字母个数)MAX。假设该英文句子中只含字母、空格和句点“.”,其中句点表示结尾,空格之间连续的字母串称为单词。[流程图]

阅读以下说明和Java程序,填补代码中的空缺(1)~(6),将解答填入答题纸的对应栏内。【说明】很多依托扑克牌进行的游戏都要先洗牌。下面的Java代码运行时先生成一副扑克牌,洗牌后再按顺序打印每张牌的点数和花色。【Java代码】

阅读下列说明和Java代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】某灯具厂商欲生产一个灯具遥控器,该遥控器具有7个可编程的插槽,每个插槽都有开关按钮,对应着一个不同的灯。利用该遥控器能够统一控制房间中该厂商所有品牌灯具的开关,现采用Command(命令)模式实现该遥控器的软件部分。command模式的类图如图6-1所示。【Java代码】}

●试题二阅读下列函数说明和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)处的语句写在答题纸的对应栏内。[说明]下面程序是一个带参数的主函数,其功能是显示在命令行中输入的文本文件内容。[C语言函数]#include"stdio.h"main(argc,argv) int argc; char *argv[]; { (1) ; if((fp=fopen(argv[1],”r’’))== (2) ) { printf(”file not open!\n”);exit(0);} while( (3) ) putchar( (4) ); (5); }

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

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

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

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