Mathematics and Family Members Essay example
Analyze, design, and document a simple program that utilizes a good design process and incorporates sequential, selection and repetitive programming statements as well as at least one function call and the use of at least one array. The specific problem you need to solve for the final project is: Design a program that will allow a user to Input a list of your family members along with their age and state where they reside. Determine and print the average age of your family and print the names of anyone who live in Texas.
2. What is the required output? What is the necessary input? How you will obtain the required output from the given input? Clearly describe variable names and definitions. Include all necessary formulas and …show more content…
2. Required outputs: Average family age, names of family members from Texas. Required inputs: Family member names, their ages and state where they reside.
Variable Declartions and defintions: Following variables will be defined:
String array s_Names to hold names.
Integer array i_Age to hold ages.
String array s_State to hold state
Integer i_Count to hold number of family members
The user entering the family names, ages and state of residence will be stored in the above described arrays such that there will be one-to-one correspondence for the indices of s_Names, i_Age, s_State arrays i.e. family member with name at index n in s_Names array will have their age and state at index n in array i_Age and s_State respectively.
Calculating average age: Average age = (sum of ages of all family members)/(Number of family members)
Example calculation: Suppose we have i_Count = 3 and i_Age = 12, i_Age = 16, i_Age = 20. Then f_avAge = (i_Age + i_Age + i_Age)/i_Count = (12 + 16 + 20)/3 = 18
In the s_State array, look for indices those contain string “Texas” and print the corresponding (at those indices) elements in s_Names.
Example calculation: Suppose s_State = “Texas”, s_State = “Texas” and s_State = “Texas” and the names array contain the following names: s_Names = “Michael”,