Enter any integer number as input. After that we match that input against different cases. If the input matches against any of the given cases then we generate the desired output.
Here is the source code of the Java Program to Accept the Height of a Person & Categorize as Taller, Dwarf & Average. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
public class Height_Category
public static void main(String args)
Scanner s = new Scanner(System.in);
System.out.print("Enter the height:");
m = s.nextInt();
if(m > 175)
System.out.println("The person is tall.");
else if(m > 155 && m <= 175)
System.out.println("The person has average height.");
System.out.println("The person is dwarf.");
$ javac Height_Category.java $ java Height_Category Enter the height:175 The person has average height.
Sanfoundry Global Education & Learning Series – 1000 Java Programs.