Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need a flow chart 4.A company has an unknown number of employees. The company de

ID: 669849 • Letter: N

Question

Need a flow chart

4.A company has an unknown number of employees. The company decided to help employees to overcome their budgeting problem as follows:

Each employee gets extra money based on the age of their dependents, if age of child is less than six, company pays $50 for each year of the child age, if age of child is less than ten, company pays $30 for each of the child age, otherwise company pays $20 for each child over ten. Design of program that prints each employee’s name, number of child/children and at end of program print total extra money company paid to the employees.

Explanation / Answer

import java.io.*;
import java.util.*;

class Dependent{
   String name;
   int age;
   public Dependent(String n,int a){
       name = n;
       age = a;
   }
}

class Employee{
   String name;
   Dependent[] children;
   public Employee(String n,Dependent[] dep){
       name = n;
       children = dep;
   }
   int wage(Dependent d){
       if (d.age <= 6) return 50;
       if (d.age > 6 && d.age <= 10) return 30;
       return 20;
   }
  
   int extra_money(){
       int total = 0;
       for (int i = 0; i < children.length; i++){
           total += wage(children[i]);
       }
       return total;
   }

   void print(){
       System.out.println(" ");
       System.out.println("Name of Employee : "+name);
       System.out.println("Number of children : "+children.length);
       System.out.println("Total extra money company paid to the employees : "+extra_money());
   }
}

class main{
   public static void main(String[] args){

   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote