Temperaturas de un día

[aux_code language=»javascript» theme=»tomorrow» title=»Temperaturas de un día» extra_classes=»»]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        double[] temp = new double[24];

        System.out.println("Intro temperatura hora 0:");
        double min = Double.parseDouble(br.readLine());
        double max = min;
        temp[0] = min;

        for (int x = 1; x < temp.length; x++) {
            System.out.println("Intro temperatura hora " + x + ":");
            double e = Double.parseDouble(br.readLine());
            temp[x] = e;
            if (e > max) {
                max = e;
            }
            if (e < min) {
                min = e;
            }
        }

        double media = 0;
        for (int x = 0; x < temp.length; x++) {
            media += temp[x];
            System.out.print(x + " ");
            for (int i = 0; i < (int) temp[x]; i++) {
                System.out.print("*");
            }
            System.out.print(" " + temp[x]);
            if (max == temp[x]) {
                System.out.println(" --> MAX");
            } else if (temp[x] <= min) {
                System.out.println(" --> MIN");
            } else {
                System.out.println(" ");
            }
        }
        System.out.println("La media es: " + String.format("%.2f", media / temp.length));
    }
}
[/aux_code]
Etiquetas: Sin etiquetas

Añadir un comentario

Debes estar conectado para publicar un comentario