/* Author : Robert Magala */ /* Assignment : 3.9 */ /* Due Date : September 2003 */ /* Platform : Java 1.41 */ /* Summary : Applet 1, input 5 #'s, find sum,small,lrg,avg,product*/ import java.awt.Graphics; import javax.swing.*; public class Applet1 extends JApplet { double one, two, three, sum, product, avg, large, small; public void init() { String num1, num2, num3; num1 = JOptionPane.showInputDialog("Enter the first number."); num2 = JOptionPane.showInputDialog("Enter the second number."); num3 = JOptionPane.showInputDialog("Enter the third number."); one = Double.parseDouble(num1); two = Double.parseDouble(num2); three = Double.parseDouble(num3); sum = one + two + three; product = one * two * three; avg = sum / 3; if(one > two) large = one; else large = two; if (three > large) large = three; if(one < two) small = one; else small = two; if(three < small) small = three; } public void paint( Graphics g ) { super.paint( g ); g.drawRect(15, 10, 270, 80); g.drawString( "The sum is " + sum, 25, 25); g.drawString( "The product is " + product, 25, 40); g.drawString( "The average is " + avg, 25, 55); g.drawString( "The smallest number is " + small, 25, 70); g.drawString( "The largest number is " + large, 25, 85); } }