// CSE 142, Spring 2010, Marty Stepp // This program prompts for the height of two people and prints // whether each one is considered tall, medium, or short. // It also prints which person is taller. // The program demonstrates the Scanner object and nested if/else statements. import java.util.*; // so that I can use Scanner public class Taller2 { public static void main(String[] args) { Scanner console = new Scanner(System.in); // read height for two people int height1 = person(console); int height2 = person(console); // print a message about which person is taller (unfinished) // if (height1 < height2) ... } // Reads information about one person's height and prints whether they are // short (under 5'3"), medium (5'3" to 5'11"), or tall (6' or over). // Returns the person's height in inches. public static int person(Scanner console) { // prompt/read height System.out.print("Height in feet and inches? "); int feet = console.nextInt(); int inches = console.nextInt(); int height = feet * 12 + inches; // print message about height range if (height < 63) { System.out.println("You are short."); } else if (height < 71) { System.out.println("You are medium."); } else { System.out.println("You are tall."); } return height; } }