This is a Java Program to Accept the Height of a Person & Categorize as Taller, Dwarf & Average.
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.
import java.util.Scanner;
public class Height_Category
{
public static void main(String args[])
{
int m;
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.");
}
else
{
System.out.println("The person is dwarf.");
}
}
}
Output:
$ javac Height_Category.java $ java Height_Category Enter the height:175 The person has average height.
Sanfoundry Global Education & Learning Series – 1000 Java Programs.
advertisement
advertisement
Here’s the list of Best Books in Java Programming, Data Structures and Algorithms.
Related Posts:
- Practice Programming MCQs
- Apply for Computer Science Internship
- Check Programming Books
- Apply for Java Internship
- Practice Information Technology MCQs