The source code to read the height of a person and the print person is taller, dwarf or average height person is given below. The given program is compiled and executed successfully.
# Ruby program to read the height of a person
# and the print person is taller, dwarf,
# or average height person
print "Enter height: ";
height = gets.chomp.to_f;
if height >= 150.0 && height <= 170.0
print "Person is average height person";
elsif height > 170.0 && height <= 195.0
print "Person is taller";
elsif height < 150.0
print "Person is dwarf";
else
print "Abnormal height";
end
Output:
Enter height: 186.2
Person is taller
Explanation:
In the above program, we read the height of a person from the user. Then we check the height of the person and printed the appropriate message based on input height that person is taller, dwarf, or average height person.
Program/Source Code:
The source code to read the height of a person and the print person is taller, dwarf or average height person is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we read the height of a person from the user. Then we check the height of the person and printed the appropriate message based on input height that person is taller, dwarf, or average height person.
need an explanation for this answer? contact us directly to get an explanation for this answer