Build class Project with id(int), desc (String), duration (int) , budget (double) and members (ArrayList of Workers). Provide parameterized constructor Project (int id, String desc, double budget). The member array will be initialized as empty array and initial duration of project will be 0. Provide setters for description & budget & getters for all except members list. Provide method addMember(Worker m) that adds worker instance to members array list. Provide a method Worker getMember(int wId) that searches for worker with given id in members list and returns instance. Provide a method addMemberHours(int wId, int h) that find Worker with wID in members list and then adds worker hours to instance. These many hours should also be added to duration of this project.( Also add 5 to the duration of this project). Provide method getTotalCost() to calculate total cost of project by summing budget and salary of each member of project. Override toString method to get output.
by CodeChum Admin
Instructions:
Input
The first line contains an integer n which is the size of the array.
The next n lines contains a string on each.
The last line contains an integer which is the index to be accessed and printed.
6
Learning
Programming
made
easy
with
Cody!
5Output
A line containing a string.
Cody!by CodeChum Admin
Did you know that you can also reverse lists and group them according to your liking with proper code? Let's try it to believe it.
Instructions:
Input
The first line contains an odd positive integer.
The next lines contains an integer.
5
1
3
4
5
2Output
A line containing a list.
[2,5]-[4]-[3,1]Make a program that will accept an integer and loop for the same number of times as that of the inputted integer and input random integers and add it to the array/list one by one, per line. Afterwards, make your program accept another random integer.
Using that final integer, compare from your array/list if the final integer's value is also present in your current array/list. If so, print "Present"; otherwise, print "None".
Start coding now!
Input
The first line contains the size of the array/list.
The next lines contain the integers.
The last line contains an integer to be searched.
5
3
21
2
5
23
2Output
A line containing a string.
PresentBuild a class Department having id(int), address(String) and Project(array list of projects) and Worker(array list of members). Provide a method addProject(int id, String description, double budget) that creates project and adds it to project list. Provide method addWorkerToProject(int projId, int wId) that searches for project with projId from projects list and worker with wId from members lists and adds member to project (you will call appropriate method of project class that will add member to project. Provide a method getProjectCost(int pid) which searches for project with given id from projects list and returns its total cost (you can call method from project class to get total cost) . Provide a method getDepartmentTotalBudget() that calculates total cost of each project of the department and adds it up to get total budget (call appropriate method of Project instances for project costs) .Provide toString of department so that it outputs all details including each project and members in each project.
Build a class Worker having id(int), name(Sting), hoursWorked(int), salRate (double)
a. Provide a constructor Worker(int id, String name, double salRate). The hoursWorked will
be initially 0
b. Provide getters for each but setters for only salRate
Provide a method addHours(int h) that increase the number of hoursWorked by the
provided value.
d. Provide a method getCurrentSalary() that calculates and returns the current salary i.e.
the hoursWorked times the salRate.
e. Override the toString to get appropriate output
Build a class Department having id (int), address (String) and projects (array list of projects) and
workers (array list of workers)
Provide parameterized constructor Department (String address) which initialized id randomly & array lists as empty array lists. Provide method addWorker(int id, String name, double salRate) that adds instance of Worker to workers list. Provide a method addProject(int id, String description, double budget) that creates project & adds it to the project list. Provide method addWorkerToProject(int projId, int wId) that searches for the project with projId from projects list and worker with wId from members lists & adds member to project (you will call appropriate method of the project class that'll add member to project.
Provide method getProjectCost(int pid) which searches for project with given id from projects list and then returns its total cost (you call method from the project class to get total cost. Provide toString of department to outputs all details.
Provide a method addProject(int id, String description, double budget) that creates a project and adds it to the project list e. Provide method addWorkerToProject(int projId, int wId) that searches for the project with projId from the projects list and worker with wId from the members lists and then adds the member to the project (you will call appropriate method of the project class that will add the member to the project. See blow the project class for details. f. Provide a method getProjectCost(int pid) which searches for the project with the given id from the projects list and then returns its total cost (you can call a method from the project class to get the total cost… see the project class for details) g. Provide a method getDepartmentTotalBudget() that calculates the total cost of each project of the department and adds it up to get the total budget (You will call appropriate method of the Project instances to get the project costs) h.
The workers work for some hours on each assigned projects which adds to the total number of hours and the salary is calculated according to the salary rate of each worker. The project duration is the total number of hours worked by each member of the project. Each project has some budget but the total cost of the project is the sum of budget and the salary of each project member. Follow these steps to build your application. 1. Build a class Department having id (int), address (String) and projects (array list of projects) and workers (array list of workers) a. Provide parameterized constructor Department (String address) which initialized id randomly and array lists as empty array lists b. Provide getters for id and address and setter for address only c. Provide a method addWorker(int id, String name, double salRate) that creates an instance of Worker and adds it to the workers list d.
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.