2023-02-18 14:09:11 +00:00
|
|
|
package aula02;
|
|
|
|
|
2023-02-17 23:33:57 +00:00
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
|
|
// Solução do exercício 10
|
|
|
|
|
|
|
|
public class RealNumbers {
|
|
|
|
public static void main(String[] args){
|
|
|
|
Scanner sin = new Scanner(System.in);
|
|
|
|
|
|
|
|
int readNumbers = 1;
|
|
|
|
|
|
|
|
System.out.println("Introduza os diversos números.");
|
|
|
|
double first = sin.nextDouble();
|
|
|
|
double max = first;
|
|
|
|
double min = first;
|
|
|
|
double sum = first;
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
double n = sin.nextDouble();
|
|
|
|
if (n == first)
|
|
|
|
break;
|
|
|
|
if (n > max)
|
|
|
|
max = n;
|
|
|
|
if (n < min)
|
|
|
|
min = n;
|
|
|
|
sum += n;
|
|
|
|
++readNumbers;
|
|
|
|
}
|
|
|
|
|
2023-02-20 14:25:36 +00:00
|
|
|
System.out.printf("Valor máximo: %f\nValor mínimo: %f\nMédia: %f\nTotal: %f\n", max, min, (float) sum/readNumbers, sum);
|
2023-02-20 10:14:11 +00:00
|
|
|
|
|
|
|
sin.close();
|
2023-02-17 23:33:57 +00:00
|
|
|
}
|
|
|
|
}
|