/* Author : Robert Magala */ /* Assignment : 3.9 */ /* Due Date : September 2003 */ /* Platform : Java 1.41 */ /* Summary : Applet 2, smallest and largest */ import java.awt.Graphics; import javax.swing.*; public class Applet2 extends JApplet { double one, two, three, four, five, large, small; public void init() { String num1, num2, num3, num4, num5; num1 = JOptionPane.showInputDialog("Enter the first number."); num2 = JOptionPane.showInputDialog("Enter the second number."); num3 = JOptionPane.showInputDialog("Enter the third number."); num4 = JOptionPane.showInputDialog("Enter the fourth number."); num5 = JOptionPane.showInputDialog("Enter the fifth number."); one = Double.parseDouble(num1); two = Double.parseDouble(num2); three = Double.parseDouble(num3); four = Double.parseDouble(num4); five = Double.parseDouble(num5); if(one > two) large = one; else large = two; if (three > large) large = three; if(four > large) large = four; if(five > large) large = five; if(one < two) small = one; else small = two; if(three < small) small = three; if(four < small) small = four; if(five < small) small = five; } public void paint( Graphics g ) { super.paint( g ); g.drawRect(15, 10, 270, 80); g.drawString( "The smallest number is " + small, 25, 45); g.drawString( "The largest number is " + large, 25, 60); } }