To calculate the mean value of a data set displayed on a frequency table you have to use the following formula:

Where
Xbar is the mean value
x' is the classmark (or midpoint) of each interval
fi is the observed frequency of each interval
n is the sample size.
To determine the sample size you have to add the observed frequencies of all intervals:

To determine the classmark of each interval you have to add the upper bond and the lower bond and divide it by 2

First interval (0-9)

Second interval (10-19)

Third interval (20-29)

Fourth interval (30-39)

Fifth interval (40-49)

Sixth interval (50-59)

Seventh interval (60-69)

Eighth interval (70-79)

Ninth interval (80-89)

Next is to multiply each classmark by the frequency of the corresponding interval:
Once you've multiplied each classmark by each frequency and added all results, you can calculate the mean value using the formula:

The average or mean age of the resident of the town is 41.5 years