Write a program in python languages that calculates the average heights of an indefinite number of males
Question:
Write a program in python languages that calculates the average heights of an indefinite number of males and females.
The program should prompt the user to enter the height of each person.
The program should also ask the user to enter if that person is a male or female:
o Create an error trap (validation loop) that validates whether the user entered a correct gender value (F or M). If not, keep prompting the user to enter a valid gender value until they do so.
The program should terminate when the user enters a non-positive number (0 or less), instead of entering a valid height.
After the user enters all persons’ heights and genders,o Display the total number of males
o Display the average height of males
o Display the total number of femaleso Display the average height of females
NOTE: Create at least 4 variables that keep track of the total number of males, the total number of females, the total height of all males, and the total height of all females. Initialize them to zero at the start of your program.
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang