Übung 2
Aufgabe 2
Übung 2.b.1:
1 | java.io |
Übung 2.b.2:
1 | import java.io.PrintWriter; |
Übung 2.b.3: PrintWriter API
1 | PrintWriter(OutputStream out, boolean autoFlush) |
Übung 2.c.2:
1 2 3 4 5 6 7 8 | package de.bht.programming1.exercise02; public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } |
Aufgabe 2.a
30 31 32 33 34 35 36 37 | public static void printSchachbrett(PrintWriter out) { for (char c = 'H'; c >= 'A'; --c) { for (int i = 1; i <= 8; ++i) { out.print(c + "" + i + " "); } out.println(); } } |
Aufgabe 2.b
21 22 23 24 25 26 27 28 | public static void printSchachbrettReverse(PrintWriter out) { for (char c = 'A'; c <= 'H'; ++c) { for (int i = 8; i >= 1; --i) { out.print(c + "" + i + " "); } out.println(); } } |
Aufgabe 2.c
13 14 15 | public static void printSchachbrett() { printSchachbrett(new PrintWriter(System.out, true)); } |
Aufgabe 2.d
17 18 19 | public static void printSchachbrettReverse() { printSchachbrettReverse(new PrintWriter(System.out, true)); } |
Leave a Reply