/** * COSC 1010 Demo #3 * Illustrates the use of Scanner class methods, while loop, and if-statement. * @author Dennis Brylow * @version 1.0,   2010 Sep 10 * */ import java.util.Scanner; public class Summer { public static void main(String args[]) { Scanner keyboard = new Scanner(System.in); int x, total = 0, count = 0; System.out.println("Enter some stuff, Ctrl-D to finish"); while (keyboard.hasNext()) { x = keyboard.nextInt(); System.out.println("The number was " + x); if (x == 5) { count++; } total += x; } System.out.println("And now I'm done."); System.out.println("The total is " + total); System.out.println("I saw number 5 " + count + " times."); } }