import java.util.Scanner; public class AdultCountingProgram { public static void main(String[] args) { int numPeople, age, adults; // Find out how many people there are System.out.print("How many people are there ? "); numPeople = new Scanner(System.in).nextInt(); // Now count the adults adults = 0; for (int i=1; i<=numPeople; i++) { System.out.print("How old is person " + i + " ? "); age = new Scanner(System.in).nextInt(); if (age >= 18) adults++; } System.out.println("There are " + adults + " adults."); } }