some code samples, various examples of simple modeling ideas and some minor algorithms.

Squares.java 288B

123456789101112131415161718
  1. import java.lang.Math;
  2. class Squares
  3. {
  4. // Print all square numbers up to a fixed limit
  5. static final int LIMIT=150;
  6. public void display(int limit)
  7. {
  8. int i;
  9. for(i=1;i*i<limit;i++)
  10. {
  11. System.out.print("The square of "+i);
  12. System.out.println(" is "+i*i);
  13. }
  14. }
  15. }