int alto; int ancho;
System.out.println("Dame el alto: ");
alto = scanner.nextInt();
System.out.println("dame el ancho: ");
ancho = scanner.nextInt();
int impresosAlto;
int impresosAncho;
do {
impresosAlto = 0;
impresosAncho = 0;
do {
System.out.print("*");
impresosAncho ;
} while (impresosAncho != ancho);
System.out.println();
impresosAlto ;
} while (impresosAlto != alto);
//
}
}
do while loop issue Hi I´d like to sort this out but when i debug it , I have issues that the "impresosalto" stand whit int 1 instead of to , and the loop keep running in an infinite loop don´t know why , any help- advice ? thanks tried to change variables here and there but nothing worked out
CodePudding user response:
It is happening because your second condition of Alto is never reached, after every iteration impresosalto becomes zero. Put impresosalto=0 outside the loop and it will work fine