怎么编写下面的程序
编写一个Applet程序:从网页转入三个数,输出其中的最大值和最小值 搜索更多相关的解决方案:
编写
----------------解决方案--------------------------------------------------------
期待中。。。。。。
----------------解决方案--------------------------------------------------------
不会的帮顶
----------------解决方案--------------------------------------------------------
顶!
----------------解决方案--------------------------------------------------------
程序不复杂。主要是窗口的知识。我也没学到这里。不过学了就不会难了
----------------解决方案--------------------------------------------------------
程序代码:
import javax.swing.JOptionPane;
import java.awt.*;
import javax.swing.*;
public class MaxTest extends JApplet {
JLabel A1;
int shuzhu[ ];
public void init()
{
Container contn = getContentPane();
contn.setLayout( new FlowLayout() );
A1 = new JLabel();
String input;
int num1, num2, num3;
input = JOptionPane.showInputDialog(" please input num1: ");
num1 = Integer.parseInt( input );
input = JOptionPane.showInputDialog(" please input num2: ");
num2 = Integer.parseInt( input );
input = JOptionPane.showInputDialog(" please input num3: ");
num3 = Integer.parseInt( input );
displayMax(num1, num2, num3);
contn.add( A1 );
}
public void displayMax( int x, int y, int z )
{
int max = 0;
max = x>y?x:y;
max = z>max?z:max;
A1.setText(""+max);
}
}
import java.awt.*;
import javax.swing.*;
public class MaxTest extends JApplet {
JLabel A1;
int shuzhu[ ];
public void init()
{
Container contn = getContentPane();
contn.setLayout( new FlowLayout() );
A1 = new JLabel();
String input;
int num1, num2, num3;
input = JOptionPane.showInputDialog(" please input num1: ");
num1 = Integer.parseInt( input );
input = JOptionPane.showInputDialog(" please input num2: ");
num2 = Integer.parseInt( input );
input = JOptionPane.showInputDialog(" please input num3: ");
num3 = Integer.parseInt( input );
displayMax(num1, num2, num3);
contn.add( A1 );
}
public void displayMax( int x, int y, int z )
{
int max = 0;
max = x>y?x:y;
max = z>max?z:max;
A1.setText(""+max);
}
}
----------------解决方案--------------------------------------------------------