Im really bad at programming just started recently and i was wondering how would you combine these for loops since they look the same except for the paramaters this program makes stairs. Thanks a bunch
import java.util.Scanner;
public class example {
public static final int SUB_HEIGHT = 4;
public static void main(String[] args) {
drawBox();
System.out.println();
}
public static void drawBox() {
int number = 1;
int i;
int j;
int k;
Scanner keyboard = new Scanner(System.in);
System.out.print("How many Rows? ");
int drawbox = keyboard.nextInt();
for (i = 1; i <= drawbox; i++) {
for (j = 1; j <= i; j++) {
System.out.print("+---");
}
for (j = 1; j <= i; j++) {
System.out.print("");
}
for (k = 1; k <= number; k++) {
System.out.print("+");
}
System.out.println();
for (j = 1; j <= i; j++) {
System.out.print("| ");
}
for (k = 1; k <= number; k++) {
System.out.print("|");
}
System.out.println();
}
for (j = 1; j < i; j++) {
System.out.print("+---");
}
for (k = 1; k <= number; k++) {
System.out.print("+");
}
}
}
you see half of the code is pretty much identical except for parameters how to you combine them