程序有点错误.输入三个数,输出最大和最小的数有时候对,有时候错.各位提我找一下??,谢谢了.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*
<applet code="xiao1" width=300 height=400>
</applet>
*/
public class xiao1 extends Applet implements ActionListener
{
Label prompt;
TextField in1,in2,in3;
Button btn;
int a=0,b=0,c=0,max,min;
public void init()
{
prompt=new Label("请先输入三个待比较的数");
in1=new TextField(8);
in2=new TextField(8);
in3=new TextField(8);
btn=new Button("比较");
add(prompt);
add(in1);
add(in2);
add(in3);
add(btn);
btn.addActionListener(this);
}
public void paint(Graphics g)
{g.drawString("最大的数:"+max,10,100);
g.drawString("最小的数:"+min,10,140);
}
public void actionPerformed(ActionEvent e)
{
a=Integer.parseInt(in1.getText());
b=Integer.parseInt(in2.getText());
c=Integer.parseInt(in2.getText());
{if(a>b)
if(a>c)
if(c>b)
{max=a;min=b;}
else
{max=a;min=c;}
else
{max=c;min=b;}
else
if(b>c)
if(c>a)
{max=b;min=a;}
else
{max=b;min=c;}
else
{max=c;min=a;}
repaint();
}
}
}