import java.text.DecimalFormat;
import java.util.Scanner;
import javax.swing.JOptionPane;
/*
 * LabExerciseFour.java
 *
 * Created on February 14, 2005, 3:59 PM
 */

/**
 *
 * @author kraynek
 */
public class LabExerciseFour {
    
    /** Creates a new instance of LabExerciseFour */
    public LabExerciseFour() {
        double sum = 0.0;
        int count = 0;
        while( true ) {
            String input = JOptionPane.showInputDialog("Do you want to enter another number?","yes");
            if( input.equals("no") ) break;
            String numbersInput = JOptionPane.showInputDialog("Enter two numbers with a decimal point");
            count += 1;
            Scanner scanner = new Scanner(numbersInput);
            double first = scanner.nextDouble();
            double second = scanner.nextDouble();
            if( first < second ) {
                sum += second;
            } else {
                sum += first;
            }// end if
        }// end while
        DecimalFormat decFmt = new DecimalFormat("#.#");
        JOptionPane.showMessageDialog(null,"The sum is " + decFmt.format(sum) + " and the average is " + decFmt.format(sum/count));
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new LabExerciseFour();
    }
    
}

