/***************************************************************/ /* Prof. Dr. Carsten Vogt */ /* FH Koeln, Fak. 07 / Nachrichtentechnik */ /* http://www.nt.fh-koeln.de/vogt */ /* */ /* Das Programm zeigt die Ein-Ausgabe von Werten der Standard- */ /* typen. */ /***************************************************************/ import java.io.*; public class AllEingabe { public static void main(String args[]) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); byte byte_zahl; short short_zahl; int int_zahl; long long_zahl; float float_zahl; double double_zahl; char char_wert; String string; System.out.println(); System.out.println("Bitte byte-Zahl eingeben: "); byte_zahl = Byte.parseByte(in.readLine()); System.out.println("Gelesene byte-Zahl: " + byte_zahl); System.out.println(); System.out.println("Bitte short-Zahl eingeben: "); short_zahl = Short.parseShort(in.readLine()); System.out.println("Gelesene short-Zahl: " + short_zahl); System.out.println(); System.out.println("Bitte int-Zahl eingeben: "); int_zahl = Integer.parseInt(in.readLine()); System.out.println("Gelesene int-Zahl: " + int_zahl); System.out.println(); System.out.println("Bitte long-Zahl eingeben: "); long_zahl = Long.parseLong(in.readLine()); System.out.println("Gelesene long-Zahl: " + long_zahl); System.out.println(); System.out.println("Bitte float-Zahl eingeben: "); float_zahl = Float.parseFloat(in.readLine()); System.out.println("Gelesene float-Zahl: " + float_zahl); System.out.println(); System.out.println("Bitte double-Zahl eingeben: "); double_zahl = Double.parseDouble(in.readLine()); System.out.println("Gelesene double-Zahl: " + double_zahl); System.out.println(); System.out.println("Bitte char-Wert eingeben: "); char_wert = (char) in.read(); in.readLine(); /* wichtig: entfernt das Returnzeichen aus dem Eingabepuffer */ System.out.println("Gelesener char-Wert: " + char_wert); System.out.println(); System.out.println("Bitte String eingeben: "); string = new String(in.readLine()); System.out.println("Gelesener String: " + string); System.out.println(); } }