For this task, you are to write code that calculates the average age of family members. Instructions Your program should ask the user to input a number of family members. The program should then repeatedly ask the user to input the age of a family member until the specified number of family members is reached. Finally, the program should output the average age of the family members based on the input values. Hint: consider which form of aggregation might be appropriate for solving this problem. If the user inputs zero for the number of family members, the program should output a friendly message informing the user that at least 1 family member is required. A function has already been defined for you which asks the user for the age of a family member. You must use this function as part of your solution.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 20PE
icon
Related questions
Question

python only
start from here:

def ask_for_age():
    age = int(input('Enter the age of a family member: '))
    return age
For this task, you are to write code that calculates the average age of family members.
Instructions
Your program should ask the user to input a number of family members. The program should then repeatedly ask the user to input the age of a
family member until the specified number of family members is reached. Finally, the program should output the average age of the family
members based on the input values.
Hint: consider which form of aggregation might be appropriate for solving this problem.
If the user inputs zero for the number of family members, the program should output a friendly message informing the user that at least 1
family member is required.
A function has already been defined for you which asks the user for the age of a family member. You must use this function as part of your
solution.
Transcribed Image Text:For this task, you are to write code that calculates the average age of family members. Instructions Your program should ask the user to input a number of family members. The program should then repeatedly ask the user to input the age of a family member until the specified number of family members is reached. Finally, the program should output the average age of the family members based on the input values. Hint: consider which form of aggregation might be appropriate for solving this problem. If the user inputs zero for the number of family members, the program should output a friendly message informing the user that at least 1 family member is required. A function has already been defined for you which asks the user for the age of a family member. You must use this function as part of your solution.
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Hiring Problem
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr