Guest User

Java Programm + Fehlermeldung

a guest
Jan 15th, 2017
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.30 KB | None | 0 0
  1. import Prog1Tools.IOTools;
  2.  
  3. public class Uhrzeitrechner {
  4. public static void main(String[] args) {
  5.  
  6. System.out.println();
  7. System.out.println("Uhrzeitrechner");
  8. System.out.println();
  9. System.out.println("1: Zeitspanne berechnen");
  10. System.out.println("2: Uhrzeit erhöhen");
  11. System.out.println();
  12. System.out.println();
  13.  
  14. int Eingabe = readline();
  15.  
  16. String uhrzeit;
  17. String uhrzeit2;
  18.  
  19. switch (Eingabe) {
  20.  
  21. case 1: System.out.println("Zeitpunkt 1 eingeben");
  22. uhrzeit = IOTools.readLine();
  23. String[] zp1 = uhrzeit.split(":");
  24. System.out.println();
  25. System.out.println("Zeitpunkt 2 eingeben");
  26. uhrzeit2 = IOTools.readLine();
  27. String[] zp2 = uhrzeit2.split(":");
  28. System.out.println();
  29.  
  30. zp1[0] = Integer.parseInt(zp1[0]);
  31. zp1[1] = Integer.parseInt(zp1[1]);
  32. zp2[0] = Integer.parseInt(zp2[0]);
  33. zp2[1] = Integer.parseInt(zp2[1]);
  34.  
  35. if (zp1[0] < 0 || zp1[0] > 24 || zp1[1] < 0 || zp1[1] > 59 || zp2[0] < 0 || zp2[0] > 24 || zp2[1] < 0 || zp2[1] > 59) {
  36.  
  37. System.out.println("Falsche Eingabe");
  38.  
  39. };
  40.  
  41.  
  42. int teil1 = zp1[0] - zp2[0];
  43. int teil2 = zp1[1] - zp2[1];
  44.  
  45. int t1 = 0;
  46. int t2 = 0;
  47.  
  48. if (teil1 < 0) {teil1 = teil1 * (-1);};
  49. if (teil2 < 0) {teil2 = teil2 * (-1);};
  50. if (teil1 < 10) {t1 = 1;};
  51. if (teil2 < 10) {t2 = 1;};
  52.  
  53. if (t1 == 0 && t2 == 0) {System.out.println("Zeitspanne beträgt: " + teil1 + "h " + teil2 + "min"); break;};
  54.  
  55. }}}
  56.  
  57.  
  58.  
  59.  
  60.  
  61. ------------------------------------------------------------------------------------------------------------------------------------------
  62.  
  63.  
  64.  
  65. C:\Users\sasch\Desktop\Java Programme\Uhrzeitrechner.java:30: error: incompatible types: int cannot be converted to String
  66. zp1[0] = Integer.parseInt(zp1[0]);
  67. ^
  68. C:\Users\sasch\Desktop\Java Programme\Uhrzeitrechner.java:31: error: incompatible types: int cannot be converted to String
  69. zp1[1] = Integer.parseInt(zp1[1]);
  70. ^
  71. C:\Users\sasch\Desktop\Java Programme\Uhrzeitrechner.java:32: error: incompatible types: int cannot be converted to String
  72. zp2[0] = Integer.parseInt(zp2[0]);
  73. ^
  74. C:\Users\sasch\Desktop\Java Programme\Uhrzeitrechner.java:33: error: incompatible types: int cannot be converted to String
  75. zp2[1] = Integer.parseInt(zp2[1]);
  76. ^
  77. C:\Users\sasch\Desktop\Java Programme\Uhrzeitrechner.java:35: error: bad operand types for binary operator '<'
  78. if (zp1[0] < 0 || zp1[0] > 24 || zp1[1] < 0 || zp1[1] > 59 || zp2[0] < 0 || zp2[0] > 24 || zp2[1] < 0 || zp2[1] > 59) {
  79. ^
  80. first type: String
  81. second type: int
  82. C:\Users\sasch\Desktop\Java Programme\Uhrzeitrechner.java:35: error: bad operand types for binary operator '>'
  83. if (zp1[0] < 0 || zp1[0] > 24 || zp1[1] < 0 || zp1[1] > 59 || zp2[0] < 0 || zp2[0] > 24 || zp2[1] < 0 || zp2[1] > 59) {
  84. ^
  85. first type: String
  86. second type: int
  87. C:\Users\sasch\Desktop\Java Programme\Uhrzeitrechner.java:35: error: bad operand types for binary operator '<'
  88. if (zp1[0] < 0 || zp1[0] > 24 || zp1[1] < 0 || zp1[1] > 59 || zp2[0] < 0 || zp2[0] > 24 || zp2[1] < 0 || zp2[1] > 59) {
  89. ^
  90. first type: String
  91. second type: int
  92. C:\Users\sasch\Desktop\Java Programme\Uhrzeitrechner.java:35: error: bad operand types for binary operator '>'
  93. if (zp1[0] < 0 || zp1[0] > 24 || zp1[1] < 0 || zp1[1] > 59 || zp2[0] < 0 || zp2[0] > 24 || zp2[1] < 0 || zp2[1] > 59) {
  94. ^
  95. first type: String
  96. second type: int
  97. C:\Users\sasch\Desktop\Java Programme\Uhrzeitrechner.java:35: error: bad operand types for binary operator '<'
  98. if (zp1[0] < 0 || zp1[0] > 24 || zp1[1] < 0 || zp1[1] > 59 || zp2[0] < 0 || zp2[0] > 24 || zp2[1] < 0 || zp2[1] > 59) {
  99. ^
  100. first type: String
  101. second type: int
  102. C:\Users\sasch\Desktop\Java Programme\Uhrzeitrechner.java:35: error: bad operand types for binary operator '>'
  103. if (zp1[0] < 0 || zp1[0] > 24 || zp1[1] < 0 || zp1[1] > 59 || zp2[0] < 0 || zp2[0] > 24 || zp2[1] < 0 || zp2[1] > 59) {
  104. ^
  105. first type: String
  106. second type: int
  107. C:\Users\sasch\Desktop\Java Programme\Uhrzeitrechner.java:35: error: bad operand types for binary operator '<'
  108. if (zp1[0] < 0 || zp1[0] > 24 || zp1[1] < 0 || zp1[1] > 59 || zp2[0] < 0 || zp2[0] > 24 || zp2[1] < 0 || zp2[1] > 59) {
  109. ^
  110. first type: String
  111. second type: int
  112. C:\Users\sasch\Desktop\Java Programme\Uhrzeitrechner.java:35: error: bad operand types for binary operator '>'
  113. if (zp1[0] < 0 || zp1[0] > 24 || zp1[1] < 0 || zp1[1] > 59 || zp2[0] < 0 || zp2[0] > 24 || zp2[1] < 0 || zp2[1] > 59) {
  114. ^
  115. first type: String
  116. second type: int
  117. C:\Users\sasch\Desktop\Java Programme\Uhrzeitrechner.java:42: error: bad operand types for binary operator '-'
  118. int teil1 = zp1[0] - zp2[0];
  119. ^
  120. first type: String
  121. second type: String
  122. C:\Users\sasch\Desktop\Java Programme\Uhrzeitrechner.java:43: error: bad operand types for binary operator '-'
  123. int teil2 = zp1[1] - zp2[1];
  124. ^
  125. first type: String
  126. second type: String
  127. 18 errors
Add Comment
Please, Sign In to add comment