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

Write a program in python languages that calculates the average heights of an indefinite number of males and females.

  1. The program should prompt the user to enter the height of each person.

  2. 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.

  3. The program should terminate when the user enters a non-positive number (0 or less), instead of entering a valid height.

  4.  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 females

    o 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.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

4 mainpy 2 3 4 Run Debug Stop printEnter the heights and gender when prompted enter or neg... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!