aufgabe 2.2 erledigt

master
farzad.h 2024-04-08 11:15:55 +02:00
parent fb1e8c0b31
commit 06d8162bc8
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,23 @@
import java.util.Scanner;
public class Console {
Scanner input = new Scanner(System.in);
public String readString() {
String text = input.nextLine();
return text;
}
public char[] readCharArray() {
String text = input.nextLine();
char[] cText = text.toCharArray();
return cText;
}
public boolean readBoolean() {
boolean bText = input.nextBoolean();
return bText;
}
}

View File

@ -0,0 +1,21 @@
public class DemoConsole {
public static void main(String[] args) throws Exception {
Console Console = new Console();
System.out.println("Text eingeben: ");
String text = Console.readString();
System.out.println("Gelesener Text: " + text);
System.out.println("Text eingeben: ");
char[] ca = Console.readCharArray();
System.out.println("Gelesenes char-Feld: ");
for (char celement : ca)
System.out.print(celement);
System.out.println();
System.out.println("Boolean eingeben: ");
boolean b = Console.readBoolean();
System.out.println("Gelesener Wert: " + b);
}
}