/** * INPUT: Three integers using three separate pop-up windows * OUTPUT: Their average rounded to two places. * */ import javax.swing.JOptionPane; import java.text.DecimalFormat; class AverageOfThreeIntegers{ public static void main(String [] args){ // Declare primitive variable // can declare and initialize a variable with one statement; int sum = 0; // Declare reference variable and create the object DecimalFormat fmt = new DecimalFormat("0.00"); String input = JOptionPane.showInputDialog("Enter first integer"); sum = Integer.parseInt(input); input = JOptionPane.showInputDialog("Enter second integer"); sum += Integer.parseInt(input); input = JOptionPane.showInputDialog("Enter third integer"); sum += Integer.parseInt(input); double average = sum / 3.0; System.out.println("The average is " + fmt.format(average)); System.exit(0); } }