Switch from 'while' loop to 'do..while'
This commit is contained in:
parent
9abee3f273
commit
d2a4a91520
|
@ -16,17 +16,16 @@ public class RealNumbers {
|
||||||
double min = first;
|
double min = first;
|
||||||
double sum = first;
|
double sum = first;
|
||||||
|
|
||||||
while (true) {
|
double n;
|
||||||
double n = sin.nextDouble();
|
do {
|
||||||
if (n == first)
|
n = sin.nextDouble();
|
||||||
break;
|
|
||||||
if (n > max)
|
if (n > max)
|
||||||
max = n;
|
max = n;
|
||||||
if (n < min)
|
if (n < min)
|
||||||
min = n;
|
min = n;
|
||||||
sum += n;
|
sum += n;
|
||||||
++readNumbers;
|
++readNumbers;
|
||||||
}
|
} while (n != first);
|
||||||
|
|
||||||
System.out.printf("Valor máximo: %f\nValor mínimo: %f\nMédia: %f\nTotal: %f\n", max, min, (float) sum/readNumbers, sum);
|
System.out.printf("Valor máximo: %f\nValor mínimo: %f\nMédia: %f\nTotal: %f\n", max, min, (float) sum/readNumbers, sum);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue