Basically the output will tell the minimum integer, sum of odd integers, and count of negative integers when the user inputs a list of numbers (Stops when user enters 0). I get the count of negative numbers correct but the problem I am encountering is that the sum of odd integers only adds when numbers are positive and the minimum integer always turns out 0. This is my code
package example2;
import java.util.Scanner;
public class ex {
public static void main(String[] args)
{ Scanner sc = new Scanner(System.in);
int oddsum=0, min=0, negcount=0;
int number;
do
{
number=sc.nextInt();
if(number< 0)
{
negcount++;
}
else if(number%2!=0)
{
oddsum+=number;
}
else if(number<min)
{
number=min;
}
}while(number!=0);
System.out.println("The minimum integer is "+min);
System.out.println("The sum of odd integers is "+oddsum);
System.out.println("The count of negative integers in the sequence is "+negcount);
}
}