Back to the Program-A-Day homepage
Problem
The problem is Edwin
|
|
Getting Started
|
Solution
The solution...
|
Code
Solution Code
import javax.swing.JOptionPane;
class RocketTree
{
private static final int TREE_HEIGHT = 10;
public static void main(String args[])
{
for (int a = 0; a < TREE_HEIGHT; a++)
{
// Make some inital space
printChar(TREE_HEIGHT - a, ' ');
// Draw zee tree
printChar(a * 2, '*');
System.out.println();
}
printChar(TREE_HEIGHT - 2 + 1, ' ');
printChar(2, '|');
System.out.println();
}
static void printChar(int howMuch, char out)
{
for (;howMuch > 0; howMuch--)
{
System.out.print(out);
}
}
}
|
Back to the Program-A-Day homepage