Ich weiß nicht welchen Fehler ich hier übersehe aber ich übersehe ihn auch nach mehrmaligem durchlesen.
Wenn ich auf "run" gehe funktioniert es mit 0, negativen und positiven Zahlen, auch der Output funktioniert.
Ich habe versucht den Code kompakt zu halten.
Bitte um Hilfe.
package de.codegym.task.task04.task0429;
/*
Positive und negative Zahlen
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String x1 = reader.readLine();
int x = Integer.parseInt(x1);
String y1 = reader.readLine();
int y = Integer.parseInt(y1);
String z1 = reader.readLine();
int z = Integer.parseInt(z1);
int a = 0; //negative Zahlen
int b = 0; //positive Zahlen
if (x>0) {
b++;
}
if (x < 0) {
a++;
}
if (y>0){
b ++;
}
if (y<0){
a ++;
}
if (z>0){
b ++;
}
if (z<0){
a ++;
}
System.out.println("Anzahl der negativen Zahlen: "+a);
System.out.println("Anzahl der positiven Zahlen: "+b);
//schreib hier deinen Code
}
}