Hello!
I get my solution rejected with the following requirements violated:
- The program should display the number of positive numbers in the original set.
- If there are no positive numbers, the program should display "0".
I copied the code to the IDE on my computer, and it works well. I tried different inputs like (-1, -1, -1), (0, -1, 1), (0, 0, 1), (-1, 1, 1), (1, 1, 1) and the examples from the problem statement, and always got the correct output. So the question is - what's going on?
package en.javarush.task.jdk13.task04.task0428;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
Positive number
*/
public class Solution {
static int count = 0;
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int a = Integer.parseInt(reader.readLine());
if (a > 0) {Solution.count ++;}
int b = Integer.parseInt(reader.readLine());
if (b > 0) {Solution.count ++;}
int c = Integer.parseInt(reader.readLine());
if (c > 0) {Solution.count ++;}
System.out.println(Solution.count);
}
}