Answer to Question #272689 in Java | JSP | JSF for Henri

Question #272689

Provide a method addMemberHours(int wId, int h) that finds the Worker with the wID in the members list and then adds worker hours to the instance. (You can call an appropriate method of the worker class for this. See details in the above section). These many hours should also be added to the duration of this project. E.G. if this method is called with arguments 2, 5, this would mean that you find the worker with id 2 in the members list and then call an appropriate method of the instance to add 5 hours to the hoursWorked of this worker. Also add 5 to the duration of this project. f. Provide a method getTotalCost() that calculates the total cost of the project by summing the budget and the salary of each member of the project. The salary of each m ember can be found by calculating an appropriate method of the Worker class g. Override the toString method to get appropriate output.  


1
Expert's answer
2021-11-29T18:45:54-0500


package workers;


import java.util.Scanner;


 class Department{
     private int id;
     private String address;
     Department(int s, String a){
         id = s;
         address = a;
     }
     
     
 }
public class Workers {
    Scanner scan = new Scanner(System.in);
void addMemberHours(int wId, int h){
    System.out.println("Enter the number of hours\n");
    int hours = scan.nextInt();
}


double getTotalCost(){
    System.out.println("Enter the salary\n");
    
    double sal = scan.nextDouble();
    System.out.println("Enter the budget\n");
    double bud = scan.nextDouble();
    return bud + sal;
     
    
}


public String toString(){
    return String.valueOf(getTotalCost());
}
    
    public static void main(String[] args) {
        
    }
    
}

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
APPROVED BY CLIENTS