I'm trying to print a figure that prints 3 spaces then a star, then the next line prints 2 spaces, / and a star, and then 1 space, // and a star and so on. I've got the code to print all the slashes and stars, but I can't figure out how to get the spaces to print with a descending number. This is for an assignment and I have to use nested for loops. Any thoughts? PS I don't want an exact answer (i.e. "type in this code"), I just want a suggestion to try to point me in the right direction.
What I have so far is (H is the scale):
public class Pattern { //program that prints a boxed-in design
public static final int H = 9;
public static void main(String[] args) {
line();
design();
}
public static void line() {
System.out.print("+");
for (int d=1; d <=H-2; d++) {
System.out.print("-");
}
System.out.println("+");
}
public static void design() {
top();
}
public static void top() {
for (int row = 1; row <=H-2; row++){
System.out.print("|");
for (int sp =3; sp>=1; sp--){
System.out.print(" ");
}
for (int fsl=1; fsl<=row-1; fsl++){
System.out.print("/");
}
for (int star=1; star<=1; star++){
System.out.print("*");
}
for (int bsl=1; bsl<=row-1; bsl++){
System.out.print("\\");
}
System.out.print("|");
System.out.println();
}
}
}