Witam. Czy jest gdzieś błąd logiczny w napisanym kodzie? Wg mnie jest 9 przypadków jakie trzeba przeanalizować. Czy jest prostszy sposób, aby wszystkie podpunkty zostały zaliczone ?
package pl.codegym.task.task04.task0429;
/*
Liczby dodatnie i ujemne
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
//tutaj wpisz swój kod
BufferedReader reader = new BufferedReader (new InputStreamReader(System.in));
String aa = reader.readLine();
int a = Integer.parseInt(aa);
String bb = reader.readLine();
int b = Integer.parseInt(bb);
String cc = reader.readLine();
int c = Integer.parseInt(cc);
if (a>0 && b>0 && c>0)
{
System.out.println("Liczba licz ujemnych: 0");
System.out.println("Liczba licz dodatnich: 3");
}
else if (a>0 && b>0 && c<0 || a>0 && c>0 && b<0 || b>0 && c>0 && a<0)
{
System.out.println("Liczba licz ujemnych: 1");
System.out.println("Liczba licz dodatnich: 2");
}
else if (a>0 && b<0 && c<0 || b>0 && a<0 && c<0 || c>0 && a<0 && b<0)
{
System.out.println("Liczba licz ujemnych: 2");
System.out.println("Liczba licz dodatnich: 1");
}
else if (a<0 && b<0 && c<0)
{
System.out.println("Liczba licz ujemnych: 3");
System.out.println("Liczba licz dodatnich: 0");
}
else if (a==0 && b>0 && c>0 || b==0 && a>0 && c>0 || c==0 && b>0 && a>0)
{
System.out.println("Liczba licz ujemnych: 0");
System.out.println("Liczba licz dodatnich: 2");
}
else if ( a==0 && b==0 && c>0 || b==0 && a>0 && c==0 || c==0 && b>0 && a==0)
{
System.out.println("Liczba licz ujemnych: 0");
System.out.println("Liczba licz dodatnich: 1");
}
else if (a==0 && b==0 && c==0)
{
System.out.println("Liczba licz ujemnych: 0");
System.out.println("Liczba licz dodatnich: 0");
}
else if ( a==0 && b<0 && c<0 || b==0 && a<0 && c<0 || c==0 && b<0 && a<0)
{
System.out.println("Liczba licz ujemnych: 2");
System.out.println("Liczba licz dodatnich: 0");
}
else if ( a==0 && b==0 && c<0 || b==0 && a<0 && c==0 || c==0 && b<0 && a==0)
{
System.out.println("Liczba licz ujemnych: 1");
System.out.println("Liczba licz dodatnich: 0");
}
}
}