Answer to Question #281529 in Java | JSP | JSF for bvhgjd

Question #281529

You are required to write builds a record book for Projects being conducted at a department. A Project has an id, description, array list of members and start and end dates. In the Project class provide two abstract methods: getTeamSize(): that finds and returns the size of the team working on this project c and calculateCost(): that finds and returns the total cost of project. Provide the class MixedTeamProject which extends Project

a. This class represents a project that can have mixed types of members

b. Override the getTeamSize() appropriately so that it counts all members but makes sure that only active adhoc members are counted if there are any

c. Provide the implementation of calculateCost method so that the cost is calculated as under:

i. Salaries are added for adhoc members

ii. Salaries of contract members are added but 11% tax is added for each contract member salary

iii. Salary of all hourly member is added and a flat amount of 1000 is added to cover additional cost


1
Expert's answer
2021-12-20T14:49:23-0500
import java.util.ArrayList;
import java.util.Date;

public abstract class Project {
    private String id;
    private String description;
    private ArrayList<Member>members;
    private Date start;
    private Date end;

    public abstract int getTeamSize();

    public abstract double calculateCost();
}


public class MixedTeamProject extends Project {
    @Override
    public int getTeamSize() {
        int size = 0;
        for (Member member : getMembers()) {
            if (member.isAdhoc()) {
                size++;
            }

        }
        return size;
    }

    @Override
    public double calculateCost() {
        double adhocSalaries = 0;
        double contractSalaries = 0;
        double hourlySalaries = 1000;
        for (Member member : getMembers()) {
            if (member.isAdhoc()) {
                adhocSalaries += member.getSalary();
            } else if (member.isContract()) {
                contractSalaries += member.getSalary() * 1.11;
            } else if (member.isHourly()) {
                hourlySalaries += member.getSalary();
            }

        }
        return adhocSalaries + contractSalaries + hourlySalaries;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog