All pastes #2075795 Raw Edit

Stuff

public text v1 · immutable
#2075795 ·published 2011-06-06 22:34 UTC
rendered paste body
import 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;
  }
}