Hi I tried making an array that stores the integers and then comparing them to 0. But I have an output error. can someone tell me what I did wrong here?
package com.codegym.task.task04.task0429;
/*
Positive and negative numbers
*/
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());
int[] nr= new int[3];
nr[0]=a;
nr[1]=b;
nr[2]=c;
int x=0;
int y=0;
for (int i=0; i<=nr.length; i++)
{
if (nr[i]>0)
x=x+1;
else if(nr[i]<0)
y=y+1; }
System.out.println("Number of positive numbers: "+x);
System.out.println("Number of negative numbers: "+y);
}
}