So my code is as follows:
if (a > 0)
a = 1;
if (b > 0)
b = 1;
if (c > 0)
c = 1;
if (a < 0 && b < 0 && c < 0)
System.out.print(0);
else
System.out.print(a + b + c);
The question is, why the program insist that number 0 is there when the code clearly states that there are no statement to number zero (hence, it shouldn't shows up on the result(?))
If I entered 0 0 0, the result would be 0, not nothing. Everything else works fine.package com.codegym.task.task04.task0428;
/*
Positive number
*/
import java.io.*;
public class Solution {
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());
int b = Integer.parseInt(reader.readLine());
int c = Integer.parseInt(reader.readLine());
if (a >= 1)
a = 1;
if (b >= 1)
b = 1;
if (c >= 1)
c = 1;
if (a < 0 && b < 0 && c < 0)
System.out.print(0);
else
System.out.print(a + b + c);
}
}