public class Sum_do_while
{
  public static void main(String args[])
  {

    TokenReader in = new TokenReader(System.in);

    int    count = 0; // major diff in count here from "while" version
    int    stop  = 0;
    double sum   = 0;
    double temp  = 0;    

    System.out.print("How many numbers do you wish to enter? ");
    System.out.flush();
    stop = in.readInt();

    do {
      System.out.print("Enter data #" + (count+1) + ": ");
      System.out.flush();
      temp = in.readDouble();
      sum = temp + sum;
      ++count;
    } while(count < stop); 
    // use "<" instead of "<=" otherwise goes one too many times
    
    System.out.println();
    System.out.println("Final sum: " + sum);
  }
}
