// CSE 142, Summer 2008 (Marty Stepp) // This program reads 10 numbers and prints how many were (non)negative. import java.util.*; public class ReadNumbers { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("Type 10 numbers: "); int nonNegative = 0; int negative = 0; // cumulative count of neg/pos numbers for (int i = 1; i <= 10; i++) { int next = console.nextInt(); if (next >= 0) { nonNegative++; } else { negative++; } } System.out.println(nonNegative + " non-negative"); System.out.println(negative + " negative"); } }