问题 写作题

假设你是李华,你上个星期天去市图书馆看书时发现以下问题,你写信向馆长Mr“反映:1.新书太少;2.书架上的书比较混乱; 3.阅览室的一盏灯坏了;4.管理员工作时彼此闲聊。

答案

Dear Mr. Li,

Last Sunday, I went to do some reading in your library. Over the time 1 was there, I found something unpleasant. Therefore, I' d like to voice nay opinions, which, I hope, would be of help for you to create a more comfortable place for readers.

First, there are few" new books on the shelf, and most books are not popular today. Second, some books are not sorted in proper order, making it difficult for readers to find what they want quickly. Third, the assistants didn't offer good service. Instead, they were chatting. In addition, they took no notice of the fact that a light wasn't working. Leave this state of affairs to stay the same, and I am afraid there will be fewer and fewer readers.

So, for the sake of readers, I suggest that you change all these as son as possible.

Yours, 

Li Hua

选择题
问答题

下面是一个Applet程序,其功能是输入3个双精度浮点数:a,b,c,构成一个一元二次方程,a*x*x+b*x+c=0,其判别式d=b*b-4*a*c,若d为负数则输出“没有实根”,否则打印出2个实根。要求,有3个输入框,输入a,b,c,一个按钮,点击实现求根过程,一个不可编辑的文本区,用作输出结果。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。
注意:不改动程序的结构,不得增行或删行。
import java. io. *
import java. awt. *
import java. awt. event. *
import java. applet. Applet;
/*
<applet code="ex3_1. class" width=800 height=400>
</applet>
*/
public class ex3_1 extends Applet implements ActionListener
Panel pane= new Panel();
Label 11=new Label("a: ")
TextField tf1 =new TextField(5)
Label 12 = new Label ("b: ")
TextField tf2=new TextField(5);
Label 13=new Label("c:")
TextField tf3=new TextField(5);
Button btn= new Button("OK")
Label 14=new Label("答案")
TextField tf4=new TextField(20);
ex3_1 obj3_1
public void init()
pane. setLayout( new FlowLayout (FlowLayout. LEFT, 10,5 ) )
pane. add(11)
pane. add(tf1)
pane. add(12)
pane. add(tf2)
add( "North", pane)
Panel p2=new Panel();
p2. setLayout ( new FlowLayout ( FlowLayout. LEFT, 10, 5) )
p2. add(13);
p2. add(tf3)
p2. add(btn)
btn. addActionListener(this);
add("Center",p2)
Panel p3=new Panel ()
p3. setLayout ( new FlowLayout (FlowLayout. LEFT, 10,5 ) )
p3. add(14)
tf4. setEditable(false)
p3. add(tf4)
add("South" ,p3)
obj3_1 = new ex3_1 ( )

public void doReal(double a1,double a2,double a3,TextField tf)
double d, x1, x2
d=a1 * a1-4.0 * a2 * a3;
if(d>=0.0)
x1=(-a2+Math. sqrt(d))/(2.0 * a1);
x2=(-a2+Math. sqrt(d))/(2.0 * a1);
tr. setText("2个实根:x1="+x1+"\nx2="+x2);

else
tr. setText ( "没有实根!")


public void actionPerformed(ActionEvent ae)
double a, b, c;
try
a= new Double(tf1. getText( ) ). doubleValue( );
b= new Double(tf2. getText( ) ). doubleValue( );
c= new Double(tf3. getText( ) ). doubleValue( );
obj3_1, doReal(a,b,c, 14);
catch(NumberFormatException nfe)
tf4. setText( "wrong number!")



ex3_l. html
<HTML>
<HEAD>
<TITLE> ex3_l </TITLE>
</HEAD>
<BODY>
<applet code="ex3_l, class" width=800 height=400>
</applet>
</BODY>
</HTML>