Java Source File
Download
/**
* HOMEWORK 2: Family Age Analyzer
* PT821 - Object-Oriented Programming
* Due Date: [Set by Instructor]
*
* ============================================================
* INSTRUCTIONS (READ CAREFULLY):
* ============================================================
*
* Create a program that analyzes YOUR REAL family members' ages.
* This homework CANNOT be copied because it uses YOUR family data.
*
* REQUIREMENTS:
* 1. Use REAL ages of at least 5 family members (parents, siblings, etc.)
* 2. Use REAL names of your family members
* 3. Include yourself in the analysis
* 4. You must be able to explain your family structure if asked
*
* TASK:
* Create a program that:
* a) Stores names and ages of 5+ family members in arrays
* b) Calculates the average age of your family
* c) Finds the oldest and youngest family member
* d) Calculates the age difference between oldest and youngest
* e) Counts how many family members are above/below average age
* f) Determines if YOU are above or below family average
* g) Uses loops for ALL calculations (no hardcoding results)
*
* EXAMPLE OUTPUT FORMAT:
* ================================================
* FAMILY AGE ANALYSIS REPORT
* Student: [Your Name] - [Your Reg Number]
* ================================================
* Family Members:
* 1. [Name] - Age: XX (Relationship: Father)
* 2. [Name] - Age: XX (Relationship: Mother)
* ... (continue for all members)
* ------------------------------------------------
* Total family members: X
* Average family age: XX.XX years
* Oldest: [Name] (XX years)
* Youngest: [Name] (XX years)
* Age gap: XX years
* Members above average: X
* Members below average: X
* I am [ABOVE/BELOW] the family average
* ================================================
*
* GRADING CRITERIA:
* - Correct use of arrays (20%)
* - Correct loop implementations (25%)
* - Accurate calculations (25%)
* - Use of YOUR real family data (30%)
*
* WARNING: You may be asked to verify family information verbally.
*/
public class Homework2_FamilyAgeAnalyzer {
public static void main(String[] args) {
// TODO: Implement your solution here
// Step 1: Create arrays for family data
// String[] names = {"Your Name", "Father Name", "Mother Name", ...};
// int[] ages = {your_age, father_age, mother_age, ...};
// String[] relationships = {"Self", "Father", "Mother", ...};
// Step 2: Calculate average using a loop
// Step 3: Find oldest and youngest using loops
// Step 4: Count above/below average using a loop
// Step 5: Display formatted report
System.out.println("// DELETE THIS LINE AND IMPLEMENT YOUR SOLUTION");
}
}