10 likes | 81 Views
/* Investigate_age.java by Kari Silpiö */ class Investigate_age { public static void main (String[] args) { /* *** DEFINITIONS *** */ int age; int minors = 0; int adults = 0; /* *** LOGICAL PART *** */
E N D
/* Investigate_age.java by Kari Silpiö */ • class Investigate_age • { • public static void main (String[] args) • { • /* *** DEFINITIONS *** */ • int age; • int minors = 0; • int adults = 0; • /* *** LOGICAL PART *** */ • System.out.print ("Enter age (zero ends ): "); • age = Keyboard.readInt ( ); • while( age > 0 ) • { • if(age < 18) • { • System.out.println ("Minor"); • minors= minors + 1; • } • else • { • System.out.println ("Adult"); • adults = adults + 1; • } • System.out.print ("Enter age (zero ends): "); • age = Keyboard.readInt ( ); • } • System.out.println (minors + " minor(s), " + • adults + " adult(s)"); • } • } DEFINITIONS age N 3 minors N 2 adults N 2 START minors = 0 adults = 0 DISPLAY "Enter age (zero ends):” ACCEPT age age > 0 FALSE TRUE age < 18 FALSE TRUE DISPLAY "Minor" DISPLAY "Adult" minors = minors + 1 adults = adults + 1 DISPLAY "Enter age (zero ends): " ACCEPT age DISPLAY minors " minor(s), " adults " adult(s)." END Kari Silpiö (transl. Birgitta Jansson-Koponen, edited by JV)