Here's a quick example of your square root task. There are many different variations of this task... you may wish to review iteration in
Java (using "for" and "while" loops). Sorry if the formatting is a bit off.
<CODE>
//package name here
/**
* A simple class to create squares of integers.
*/
public class SquareRootGen { /**
* Creates a new <code>SquareRootGen</code> instance.
*/
public SquareRootGen (){
} /**
* <code>main</code> method that does the work
*/
public static void main(String args []) { // create your max integer value
int max = 21; // create a square root value
int j = 0; // iterate through starting from zero to one int less than the max value
// it will start from zero and end at 20
for (int i = 0; i < max; i++) { // assign the value of i times i to j
j = i*i; // print your statement
System.out.println("The square of " +i +" is " +j +".");
}
}
}// SquareRootGen
</CODE>
[This message has been edited by Biju Philip (edited December 20, 2001).]
[This message has been edited by Biju Philip (edited December 20, 2001).]
[This message has been edited by Biju Philip (edited December 20, 2001).]