by writing a loop and adding a print statement in it:
step 1:
highBorder = readInHighBorder
step 2:
counter = 1
step 3:
while ( counter < highBorder ){
squareRoot = calculateTheSquareRootOfCounter
printSquareRoot
cubeRoot = calculateTheCubeRootOfCounter
printCubeRoot
add1ToCounter
}
stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
I'm assuming you're doing this to learn Java, so this should get you started:
int counter = 0; // Declare your variables
int value = 1;
int max = 10; // You can define ("hard code") this, or read it in
while(counter < max) {
System.out.println(value + " "); // This handles printing
value = value * 2;
counter++; // This will track how many numbers have already been printed
}
You can use that as a basis for figuring out the cubic part. The mechanics are essentially the same.
two remarks:
1 -> don't spoon feed code.
2 -> if you feel the need to spoon feed code anyway, make sure your code makes sense. I doubt you'll find the square root of 25 by value= value*2
stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433