Java :: Aufgabe #23 :: Lösung #1
10 Lösungen

#23
Programmier-Basics: Eingabezähler
Anfänger - Java
von Freki
- 27.12.2012 um 15:01 Uhr
Schreiben Sie ein Programm, das ein Wort einliest. Das Wort wird dann so oft ausgegeben, wie es Buchstaben hat:
Konsolenausgabe:
Geben Sie ein Wort ein:
Hello
Hello
Hello
Hello
Hello
Hello
#1

von 0 (0 Punkte)
- 30.07.2013 um 17:06 Uhr
Main.java
Java-Code

package de.trainyourprogrammer.java23; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * Request and check an order. * * @author jsb */ public class Main { /** * Execute the program. * * @param args * Is ignored in our case. */ public static void main(String[] args) { BufferedReader buffer = new BufferedReader(new InputStreamReader( System.in)); // start reading from the default input System.out.println("Geben Sie ein Wort ein:"); // request a word try { // try to... String word = buffer.readLine(); // read word System.out.println(); // print empty line for (int i = 0; i < word.length(); i++) { // for each character in // the word System.out.println(word); // print the word } } catch (IOException e) { // ignore occurring IOExceptions } finally { // on quit... try { // try to... buffer.close(); // stop reading the input } catch (IOException e) { // again ignore occurringIOExceptions } } } }
Kommentare:
Für diese Lösung gibt es noch keinen Kommentar
Seite 1 von 0
1