Related Articles

# Java Program to Categorize Taller, Dwarf and Average by Height of a Person

• Last Updated : 20 Nov, 2020

In this program, categorize taller, dwarf, and average by the height of a person. For comparison, a standard height of reference is taken into consideration as 151cm to 175cm. Height ranging from the limit of 151cm to 175cm comes under average height. Height greater than 175cm comes under the taller height category and height below 150cm comes under the Dwarf category.

Example:

```Input:    164
Output: This person has Average height

Input:    180
Output: This person is taller
```

Implementation:

## Java

 `// Java Program to Categorize Taller,``// Dwarf and Average by Height of a Person`` ` `class` `Height_classifier {``    ``public` `static` `void` `main(String[] args)``    ``{``        ``int` `height = ``180``;`` ` `        ``if` `(height > ``175``) {``            ``// prints that person is taller``            ``System.out.println(``"This person is Taller"``);``        ``}``        ``else` `if` `(height > ``150` `&& height <= ``175``) {``            ``// prints that person has average height``            ``System.out.println(``                ``" This person has Average height"``);``        ``}``        ``else` `{``            ``// prints that person is a graph``            ``System.out.println(``" This person is Dwarf"``);``        ``}``    ``}``}`
Output
```This person is Taller

```

Implementation using Command line arguments:

## Java

 `// Java Program to Categorize Taller,``// Dwarf and Average by Height of a Person`` ` `class` `Height_classifier {``    ``public` `static` `void` `main(String[] args)``    ``{``        ``System.out.println(``            ``"Enter the height in centimeters:"``);``        ``// taking input from user using command line``        ``int` `height = Integer.parseInt(args[``0``]);``        ``if` `(height > ``175``) {``            ``// prints that person is taller``            ``System.out.println(``"This person is Taller"``);``        ``}``        ``else` `if` `(height > ``150` `&& height <= ``175``) {``            ``// prints that person has average height``            ``System.out.println(``                ``" This person has Average height"``);``        ``}``        ``else` `{``            ``// prints that person is a graph``            ``System.out.println(``" This person is Dwarf"``);``        ``}``    ``}``}`

Output:

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up