Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package oop;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class IO {
- static BufferedReader bufferReader = new BufferedReader(new InputStreamReader(System.in));
- public static String readString() throws IOException {
- return bufferReader.readLine();
- }
- public static int readInteger() throws IOException {
- String nummer = bufferReader.readLine();
- int nummer1 = Integer.parseInt(nummer.trim());
- return nummer1;
- }
- public static double readDouble() throws IOException {
- String nummer = bufferReader.readLine();
- double nummer1 = Double.parseDouble(nummer.trim());
- return nummer1;
- }
- public static boolean readBoolean() throws IOException {
- String answer = readString().trim();
- return answer.equalsIgnoreCase("j") ||
- answer.equalsIgnoreCase("ja") ||
- answer.equalsIgnoreCase("y") ||
- answer.equalsIgnoreCase("yes");
- }
- public static double[] readDoubleArray(int laenge) throws IOException {
- double[] zahlen = new double[laenge];
- for(int i = 0; i < zahlen.length; i++) {
- System.out.print("Wert " + (i + 1) + ": ");
- zahlen[i] = IO.readInteger();
- }
- return zahlen;
- }
- public static double[][] readDoubleArrayDouble(double laenge) throws IOException {
- double[][] zahlen = new double[(int) laenge][(int) laenge];
- for(int i = 0; i < zahlen.length; i++) {
- for (int j = 0; j < zahlen[i].length; j = j + 1) {
- System.out.print("Platz " + (i + 1) + ": ");
- zahlen[i][j] = IO.readDouble();
- }
- }
- return zahlen;
- }
- public static void writeDoubleArray(double[] readingNumbers) throws IOException {
- for(int i = 0; i < readingNumbers.length; i++) {
- System.out.println("Wert " + (i + 1) + ": " + readingNumbers[i]);
- }
- }
- public static int amount() throws IOException {
- System.out.print("Geben sie die Menge ihrer Zahlen an: ");
- int amount = IO.readInteger();
- System.out.println("Geben Sie ihre Zahlen ein: ");
- return amount;
- }
- public static double amountDouble() throws IOException {
- System.out.println("Geben Sie die Anzahl der Reihen ein: ");
- double amountDouble = IO.readDouble();
- System.out.println("Geben Sie die Anzahl der Plätze ein: ");
- return amountDouble;
- }
- public static int amountString() throws IOException {
- System.out.println("Wie viele Zeilen möchten Sie eingeben? ");
- int amountString = IO.readInteger();
- System.out.println("Geben Sie ihren Text ein: ");
- return amountString;
- }
- public static String[][] readStringArray(int zeile) throws IOException {
- String[][] text = new String[zeile][zeile];
- for (int i = 0; i < text.length; i++) {
- for (int j = 0; j < text[i].length; j = j + 1) {
- System.out.print("Zeile " + (i + 1) + ": ");
- text[i][j] = IO.readString();
- }
- }
- return text;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement