该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
class Panela extends Panel{
TextField t1;
Panela(){
setLayout(new GridLayout(1,2));
t1=new TextField();
add(new Lable("请输入要做的题数"));
add(t1);
}
}
class Panelb extends Panel{
TextField t2,t3;
Panelb(){
setLayout(new GridLayout(1,4));
int q=Integer.parseInt(A.t1.getText());
int s=100/q;
int t=0;
for(int i=1;i<=q;i++){
t2=new TextField("请回答第"+i+"道题");
char[] arr=new char[]{'+','-','*','/'};
double dNum=Math.random();
int x1=(int)(dNum*50);
int x2=(int)(dNum*100);
int x=(int)(dNum*4);
switch(x){
case 0:System.out.print("请计算\n"+x1+"-"+x2+"=");break;
case 1:System.out.print("请计算\n"+x1+"+"+x2+"=");break;
case 2:System.out.print("请计算\n"+x1+"×"+x2+"=");break;
case 3:System.out.print("请计算\n"+x1+"÷"+x2+"=");break;
}
if(x==0){
t3=new TextField("请计算\n"+x1+"-"+x2+"=?");
}
else if(x==1){
t3=new TextField("请计算\n"+x1+"+"+x2+"=?");
}
else if(x==2){
t3=new TextField("请计算\n"+x1+"×"+x2+"=?");
}
else if(x==3){
t3=new TextField("请计算\n"+x1+"÷"+x2+"=?");
}
}
}
}
class Panelc extends Panel{
TextField text;
Panelc(){
setLayout(new GridLayout(1,2));
text=new TextField();
add(new Label("计算结果"));
add(text);
}
public class calculate extends Applet implements ActionListener {
Panela A;Panelb B;Panelc C;
public void init(){
setLayout(new GridLayout(2,1));
A=new Panela();B=new Panelb();C=new Panelc();
add(A);add(B);add(C);
}
public void ActionPerformed(ActionEvent e);{
double a;
double a=Integer.parseInt(C.t.getText());
int sum=0;
int t=0;
if(sum==a){
t=t+B.s;
}
}
}