/* Write a program segment that reads a sequence of integers until a 0 is encountered, and outputs the number of non-zero numbers read. For example, if the input is: 2 13 -7 21 -11 0 The code will read in all the integers, and produce the following output: Number of non-zero integers: 5 */ import java.util.Scanner; public class HW4q2a { public static void main(String[] args) { Scanner kb=new Scanner(System.in); int userInt=kb.nextInt(); int count=0; while (userInt!=0) { count++; userInt=kb.nextInt(); } System.out.println("Number of non-zero integers: "+count); } }