I have a problem with an exercise that asks me to make a hollow rectangle made with asterisks, so that the height and width is entered by keyboard.
The code I have is the following:
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Introduce la altura");
int alt = sc.nextInt();
System.out.print("Introduce la anchura");
int anch = sc.nextInt();
String aux = "*";
for (int i = 0; i < alt-1; i++) {
System.out.println(aux);
}
for (int j = 0; j < anch; j++) {
System.out.print(aux + " ");
}
}
I can print the left side and the base but I do not know how to do the rest