Okay, so this is a similar error to the code before.
So I created this:
import java.util.Scanner;
public class IntegerCount
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print("Enter an integer, the input ends if it is 0: ");
int num = input.nextInt();
if (num == 0)
{
System.out.println("No numbers were entered except 0");
}
else if (num != 0)
{
System.out.println("The number of integers is " + num);
}
else
{
System.out.print(num);
}
}
}
But i begin to notice that when I run the program, it collects random numbers. For example, the professor expects the number 9, my program pulls out a 2? I don't see where i am making that mistake?