so soll ich ein Programm erstellen, das eine Box aus Sternen erstellt und bis jetzt wird es nicht korrekt angezeigt, manchmal sind die Spalten zu klein, manchmal zu groß, aber nie wo sie sein müssen. Kann mir bitte jemand helfen!Mein Sternchen-Programm funktioniert nicht richtig
import java.util.Scanner;
public class DisplayBox {
public static void drawBar(int length){
for (int i = 1; i <= length; i++){
System.out.print("*");
}
}
public static void drawHeight(int height, int length){
int h = 0;
while (h++ < length - 2){
System.out.print("*");
int h1 = 0;
while (h1++ < length - 2){
System.out.print(" ");
}
System.out.println(" *");
}
}
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Please enter the length of the Box: ");
int length = input.nextInt();
System.out.println("Please enter the height!: ");
int height = input.nextInt();
System.out.println();
drawBar(length);
drawHeight(height, length);
drawBar(length);
}
}