ADVERTISEMENT
ADVERTISEMENT

# Java program to read the height of the person, and the print person is taller, dwarf, or average height person

Given the height of a person, we have to read the height of the person, and the print person is taller, dwarf, or average height person.
Submitted by Nidhi, on March 01, 2022

Problem Solution:

In this program, we will read the height of the person in centimetres and print the message based on input height.

Program/Source Code:

The source code to print person is taller, dwarf, or average height person is given below. The given program is compiled and executed successfully.

```// Java program to read the height of the person,
// and the print person is taller, dwarf,
// or average height person

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner SC = new Scanner(System.in);

double height = 0;

System.out.printf("Enter Height (in centimeters): ");
height = SC.nextDouble();

if ((height >= 150.0) && (height <= 170.0))
System.out.printf("Person is average height person");
else if ((height > 170.0) && (height <= 195.0))
System.out.printf("Person is taller");
else if (height < 150.0)
System.out.printf("Person is dwarf");
else
System.out.printf("Abnormal height \n");
}
}
```

Output:

```Enter Height (in centimeters): 174.34
Person is taller
```

Explanation:

In the above program, we imported the "java.util.Scanner" package to read input from the user. And, created a public class Main. It contains a static method main().

The main() method is an entry point for the program. Here, we read the height of the person in centimeters from the user using the Scanner class. Then we printed the appropriate message.

ADVERTISEMENT
ADVERTISEMENT

Preparation

What's New

ADVERTISEMENT

Top Interview Coding Problems/Challenges!

ADVERTISEMENT

ADVERTISEMENT

Comments and Discussions!

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.