import javax.swing.JOptionPane;

public class FunEsterne {
    public static int temperaturaMassima(Termometro ter) {
        String s;
        int t;
        int max = ter.celsius();
        s = JOptionPane.showInputDialog("Temperatura:");
        while (s != null) {
            t = Integer.parseInt(s);
            ter.misura(t);
            if (ter.celsius() > max ) max = ter.celsius();
            s = JOptionPane.showInputDialog("Temperatura:");
        }
        return max;
    }

    public static int temperaturaMedia(Termometro ter) {
        String s;
        int t;
        
        int sommaTemperature = 0;
        int numeroLetture = 0;
        
        s = JOptionPane.showInputDialog("Temperatura:");
        while (s != null) {
            t = Integer.parseInt(s);
            ter.misura(t);
            sommaTemperature = sommaTemperature + ter.celsius();
            numeroLetture++;
            s = JOptionPane.showInputDialog("Temperatura:");
        }
        return sommaTemperature/numeroLetture;
    }
}
