Source of Mystery.java


  1: public class Mystery 
  2: {
  3:    public static void main( String args[] )
  4:    {
  5:       int y;
  6:       int x = 1;
  7:       int total = 0;
  8: 
  9:       while ( x <= 10 ) 
 10:       {
 11:          y = x * x;
 12:          System.out.println( y );
 13:          total += y;
 14:          ++x;
 15:       } // end while
 16: 
 17:       System.out.printf( "Total is %d\n", total );
 18:    } // end main
 19: 
 20: } // end class Mystery
 21: 
 22: 
 23: /**************************************************************************
 24:  * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and               *
 25:  * Pearson Education, Inc. All Rights Reserved.                           *
 26:  *                                                                        *
 27:  * DISCLAIMER: The authors and publisher of this book have used their     *
 28:  * best efforts in preparing the book. These efforts include the          *
 29:  * development, research, and testing of the theories and programs        *
 30:  * to determine their effectiveness. The authors and publisher make       *
 31:  * no warranty of any kind, expressed or implied, with regard to these    *
 32:  * programs or to the documentation contained in these books. The authors *
 33:  * and publisher shall not be liable in any event for incidental or       *
 34:  * consequential damages in connection with, or arising out of, the       *
 35:  * furnishing, performance, or use of these programs.                     *
 36:  *************************************************************************/