A company has an unknown number of employees The company dec
Solution
Follow the step:
package Chegg;
 import java.util.List;
 public class Employee {
    private String name;
    private int numOfChild = 0;
    private List<Integer> childAge = null;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getNumOfChild() {
        return numOfChild;
    }
    public void setNumOfChild(int numOfChild) {
        this.numOfChild = numOfChild;
    }
    public List<Integer> getChildAge() {
        return childAge;
    }
    public void setChildAge(List<Integer> childAge) {
        this.childAge = childAge;
    }
 }
package Chegg;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Scanner;
 public class Company {
    public static void main(String[] args) {
        List<Employee> empList = new ArrayList<>();
        Employee emp = null;
        int choice = 0;
        Scanner scan = new Scanner(System.in);
        for (;;) {
            System.out.println(\"Enter 1. Add Employee 2. Print Detail 3.Exit\");
            choice = scan.nextInt();
            switch (choice) {
            case 1:
                List<Integer> childAge = new ArrayList<Integer>();
                emp = new Employee();
                System.out.println(\"Enter Employee Name:\");
                emp.setName(scan.next());
                System.out.println(\"Enter the number of child/childer\");
                emp.setNumOfChild(scan.nextInt());
                for (int i = 0; i < emp.getNumOfChild(); i++) {
                    System.out.println(\"Enter the age of \" + (i + 1) + \" child\");
                    childAge.add(scan.nextInt());
                }
                emp.setChildAge(childAge);
                empList.add(emp);
                break;
            case 2:
                printDetail(empList);
            default:
                break;
            }
        }
    }
    private static void printDetail(List<Employee> empList) {
        int totalMoney = 0;
        for (int i = 0; i < empList.size(); i++) {
            System.out.println(\"---------------------------------------------\");
             System.out.println(\"Name: \" + empList.get(i).getName());
            System.out.println(\"No of children: \" + empList.get(i).getNumOfChild());
            System.out.println(\"---------------------------------------------\");
             for (int j = 0; j < empList.get(i).getNumOfChild(); j++) {
                if (empList.get(i).getChildAge().get(j) < 6) {
                    totalMoney = totalMoney + (50 * empList.get(i).getChildAge().get(j));
                } else {
                    if (empList.get(i).getChildAge().get(j) < 10) {
                        totalMoney = totalMoney + (30 * empList.get(i).getChildAge().get(j));
                    } else {
                        totalMoney = totalMoney + (20 * empList.get(i).getChildAge().get(j));
                    }
                }
            }
        }
        System.out.println(\"Total extra money that company paid to employees are: $\" + totalMoney);
        System.out.println(\"____________________________________________________\");
     }
 }


