Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. package oop;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6.  
  7. public class IO {
  8. static BufferedReader bufferReader = new BufferedReader(new InputStreamReader(System.in));
  9. public static String readString() throws IOException {
  10.  
  11. return bufferReader.readLine();
  12. }
  13.  
  14.  
  15. public static int readInteger() throws IOException {
  16.  
  17. String nummer = bufferReader.readLine();
  18. int nummer1 = Integer.parseInt(nummer.trim());
  19. return nummer1;
  20. }
  21.  
  22.  
  23. public static double readDouble() throws IOException {
  24.  
  25. String nummer = bufferReader.readLine();
  26. double nummer1 = Double.parseDouble(nummer.trim());
  27. return nummer1;
  28. }
  29.  
  30.  
  31. public static boolean readBoolean() throws IOException {
  32. String answer = readString().trim();
  33. return answer.equalsIgnoreCase("j") ||
  34. answer.equalsIgnoreCase("ja") ||
  35. answer.equalsIgnoreCase("y") ||
  36. answer.equalsIgnoreCase("yes");
  37.  
  38. }
  39.  
  40. public static double[] readDoubleArray(int laenge) throws IOException {
  41. double[] zahlen = new double[laenge];
  42. for(int i = 0; i < zahlen.length; i++) {
  43. System.out.print("Wert " + (i + 1) + ": ");
  44. zahlen[i] = IO.readInteger();
  45. }
  46. return zahlen;
  47. }
  48.  
  49. public static double[][] readDoubleArrayDouble(double laenge) throws IOException {
  50. double[][] zahlen = new double[(int) laenge][(int) laenge];
  51. for(int i = 0; i < zahlen.length; i++) {
  52. for (int j = 0; j < zahlen[i].length; j = j + 1) {
  53. System.out.print("Platz " + (i + 1) + ": ");
  54. zahlen[i][j] = IO.readDouble();
  55. }
  56. }
  57. return zahlen;
  58. }
  59.  
  60. public static void writeDoubleArray(double[] readingNumbers) throws IOException {
  61. for(int i = 0; i < readingNumbers.length; i++) {
  62. System.out.println("Wert " + (i + 1) + ": " + readingNumbers[i]);
  63. }
  64. }
  65.  
  66. public static int amount() throws IOException {
  67. System.out.print("Geben sie die Menge ihrer Zahlen an: ");
  68. int amount = IO.readInteger();
  69. System.out.println("Geben Sie ihre Zahlen ein: ");
  70. return amount;
  71. }
  72.  
  73. public static double amountDouble() throws IOException {
  74. System.out.println("Geben Sie die Anzahl der Reihen ein: ");
  75. double amountDouble = IO.readDouble();
  76. System.out.println("Geben Sie die Anzahl der Plätze ein: ");
  77. return amountDouble;
  78. }
  79.  
  80. public static int amountString() throws IOException {
  81. System.out.println("Wie viele Zeilen möchten Sie eingeben? ");
  82. int amountString = IO.readInteger();
  83. System.out.println("Geben Sie ihren Text ein: ");
  84. return amountString;
  85. }
  86.  
  87. public static String[][] readStringArray(int zeile) throws IOException {
  88. String[][] text = new String[zeile][zeile];
  89. for (int i = 0; i < text.length; i++) {
  90. for (int j = 0; j < text[i].length; j = j + 1) {
  91. System.out.print("Zeile " + (i + 1) + ": ");
  92. text[i][j] = IO.readString();
  93. }
  94. }
  95. return text;
  96. }
  97.  
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement