The task calls for a number of positive numbers to be returned. I created strings within if statements to answer the problem. It has not worked.
Is there a way in Java to count only the number of "true" values? Am I overthinking this task?
package en.codegym.task.jdk13.task04.task0428;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
Positive number
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
//keyboard entry
BufferedReader reader = new BufferedReader (new InputStreamReader(System.in));
String first = reader.readLine();
String second = reader.readLine();
String third = reader.readLine();
int a = Integer.parseInt(first);
int b = Integer.parseInt(second);
int c = Integer.parseInt(third);
//Display count of positive numbers
if (a > 0 && b > 0 && c > 0)
{
System.out.println("3");
}
if (a < 0 && b > 0 && c > 0)
{
System.out.println("2");
}
if (a > 0 && b < 0 && c > 0)
{
System.out.println("2");
}
if (a > 0 && b > 0 && c < 0)
{
System.out.println("2");
}
if (a > 0 && b < 0 && c < 0)
{
System.out.println("1");
}
if (a < 0 && b > 0 && c < 0)
{
System.out.println("1");
}
if (a < 0 && b < 0 && c > 0)
{
System.out.println("1");
}
else
{
System.out.println("0");
}
}
}