working on program which has to determine
1.the average of the age of input people
2. how many are adult among them and write the number of adults only (example if I have 15 16 24 and 26..program has to write only 2 adults
now with first part, no problem
second part is the problem
how do I get the program to write the amount of people over 18 years
You need to check age of each student to determine if he/she is adult or not. Each time you encounter an adult you will increase the counter. As you are reading inputs in loop so you will
1. Have to check if age meets with adult criteria (if condition)
2. Have to increase the counter when age meets the condition(counter++) otherwise do nothing.
and off course all this will happen inside the loop unless you want to store ages of all students somewhere, which is not required.
Do not wait to strike till the iron is hot; but make it hot by striking....
Hey guys thanks
after banging my head for a while and your help I managed to get something right but now I have another problem
I can't seem to get the average of ages right
I know it has to do with the " age+=" on line 14 but I can't get that part right
If I leave the " age+=" my number of adults count is screwed but average age is fine
if I take it out " age=" my number of adults is good but then my average is screwed
how to go about this