rendered paste bodyimport static pt.ua.prog.WIO.*;
class ex1Teste
{
static int MAX_ELEMS = 20;
public static void main(String [] args)
{
double [] nValores = new double [MAX_ELEMS];
int total;
total = lerNumeros(nValores);
println("O nº de valores lidos é : " + total);
}
static int lerNumeros(double[] nvalores)
{
int count = 0;
double valor;
do
{
valor = readDouble("Introduza um número: ");
if(valor<0 && valor!=-20)
{
println("Apenas nº positivos!");
}
else if(valor==-20)
{
nvalores[count] = valor;
count++;
}
}while(count<MAX_ELEMS && valor!=-20);
return count;
}
}