This is supposed to be a refresher assignment for start of 2nd semester, and for some reason my program is endlessly looping. The assignment is to take inputs and output the sum of positive integers, the count of even integers, etc.
The only time my program will break the loop is if the first input is 0, if the first input is not 0, no matter what, my program will not output anything.
import java.util.Scanner;
public class Assignment2{
public static void main(String args[]){
Scanner in = new Scanner(System.in);
int min = 0;
int count = 0;
int sumpos = 0;
int evencount = 0;
int input = in.nextInt();
int temp = 0;
while(input != 0){
count++;
if(input %2 == 0){
evencount++;
}
if(input > 0){
temp = sumpos;
sumpos = temp + input;
}
if(input < min){
min=input;
}
}
System.out.println("The minimum integer is " + min);
System.out.println("The count of integers is " + count);
System.out.println("The sum of positive integers is " + sumpos);
System.out.println("The count of even integers in the sequence is " + evencount);
in.close();
}
}