In a company of Clergymen, Doctors and Lawyers it is found that the sum of the ages of all present is 2160; their average age is 36; the average age of the Clergymen and the Doctors is 39; the average age of the Doctors and the Lawyers is (32 + 8/11); the average age of the Clergymen and the Lawyers is (36 + 2/3).
If each Clergymen had been 2 years older, each Lawyer 5 years older, and each Doctor 7 years older, then the average age of everyone present would have been greater by 5 years.
Determine the number of each profession present and their average ages.
If there are C clergymen, D doctors and L lawyers, whose respective average ages are c, d and l, then
C+D+L = 2160/36 = 60
Cc+Dd+Ll = 2160
(Cc+Dd)/(C+D) = 39
(Ll+Dd)/(L+D) = 360/11
(Cc+Ll)/(C+L) = 110/3
(2C+5L+7D)/60 = 5
The program is designed to solve these simultaneously. All solutions to the first and last equations for C, D and L are printed, and if the middle four equations hold, then the average ages are printed also.
C, D and L are the variables nc, nd and nl.
The variables tac, tad and tal represent Cc, Dd and Ll, that is, the product of the numbers of the respective professions by their average ages.
CLS
PRINT " C D L"
FOR nc = 1 TO 58
FOR nd = 1 TO 60 - nc - 1
nl = 60 - nc - nd
IF 2 * nc + 5 * nl + 7 * nd = 300 THEN
PRINT USING "### ### ###"; nc; nd; nl
tacd = 39 * (nc + nd)
tadl = 360 * (nl + nd) / 11
tacl = 110 * (nc + nl) / 3
IF tacd + tadl + tacl = 2 * 2160 THEN
tac = (tacd + tacl - tadl) / 2
tad = (tacd + tadl - tacl) / 2
tal = (tadl + tacl - tacd) / 2
PRINT USING " ### ### ###"; tac / nc; tad / nd; tal / nl
END IF
END IF
NEXT
NEXT
C D L
2 3 55
4 6 50
6 9 45
8 12 40
10 15 35
12 18 30
14 21 25
16 24 20
45 35 30 (these are the average ages of the groups in the line above)
18 27 15
20 30 10
22 33 5
The only consistent set is: 16 clergymen of average age 45, 24 doctors of average age 35, and 20 lawyers of average age 30.
|
Posted by Charlie
on 2010-09-16 21:51:04 |