/** * @author mh * @version 1.0 * @date 10.04.2010 * @class ForDemo3 */ import java.util.Scanner; class ForDemo3 { // Ausgabe eines variablen Blockes von '*' public static void main(String[] args) { Scanner in = new Scanner(System.in); int breite, hoehe; System.out.println("Ausgabe eines variablen Blockes von '*'\n"); System.out.println("Bitte gewuenschte Breite eingeben: "); breite = in.nextInt(); System.out.println("Bitte gewuenschte Hoehe eingeben: "); hoehe = in.nextInt(); // gefuellter Block System.out.println("\ngefuellter Block\n"); for (int i=1;i<=hoehe;i++){ for (int j=1;j<=breite;j++){ System.out.print("*"); } // for j System.out.println(); } // for i // hohler Block System.out.println("\nhohler Block\n"); for (int i=1;i<=hoehe;i++) { if (i==1 || i==hoehe) { // obere bzw untere Kante for (int j=1;j<=breite;j++) { System.out.print("*"); } // for j System.out.println(); } else { // hohler Bereich for (int j=1;j<=breite;j++) { if (j==1 || j==breite) { System.out.print("*"); } else { System.out.print(" "); } // if } // for j System.out.println(); } // if } // for i } // main } // ForDemo3