Write a Java program to generate age gender statistics

Here is a very simple Java program that generates age and gender statistics for a group of persons:

This program defines a map called persons, which stores the age and gender of each person as a key-value pair. The program then iterates through the map, updating counters for the number of males and females, and the total age of the group. Finally, it calculates the average age of the group and prints the age and gender statistics to the console.

You can modify this program by adding or removing persons from the persons map, or by changing the values in the map to reflect the ages and genders of the persons you want to include in your statistics.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: