#C10103. Calculate Infection Rates in a Community Trial
Calculate Infection Rates in a Community Trial
Calculate Infection Rates in a Community Trial
In a community trial, participants are classified into one of three age groups: Child, Adult, and Senior. Each participant's record is given as a string in the format Group Status, where Group is one of the three groups and Status is either Y
(indicating infected) or N
(not infected).
Your task is to calculate the infection rate for each of these groups using the formula:
\(\text{Infection Rate} = \frac{\text{Number of Infected Participants}}{\text{Total Participants in the Group}} \times 100\)
If a group has no participants, output No Data
for that group.
The final output should list the infection rates for Child, Adult, and Senior groups in that order, each on a separate line.
inputFormat
The input is read from standard input and has the following format:
- The first line contains an integer M representing the number of participants.
- The next M lines each contain a record in the format:
Group Status
, whereGroup
is eitherChild
,Adult
, orSenior
andStatus
isY
(infected) orN
(not infected).
outputFormat
For each of the three groups (Child, Adult, and Senior), output the infection rate on a separate line. The infection rate should be a percentage formatted to six decimal places. If a group has no records, print No Data
instead.
9
Child Y
Child N
Adult N
Adult Y
Adult N
Senior N
Senior Y
Senior Y
Child N
33.333333
33.333333
66.666667
</p>