1.4k views
0 votes
Define a method findNumPeople() that takes two integer parameters as a project's priority and the number of project tasks, and returns the number of people required for this project as an integer. The number of people is returned as follows:

Number of people required

Priority < 50 tasks 50 - 124 tasks ≥ 125 tasks

1 65 70 85

2 45 50 55

3 25 30 35

If priority number is not in the above table, return 16.

Ex: If the input is 1 45, then the output is:

65
Java program please.

User Hritik
by
7.6k points

1 Answer

6 votes
Here's a Java program that implements the findNumPeople() method:

```
public class Project {
public static int findNumPeople(int priority, int numTasks) {
if (numTasks < 50) {
if (priority == 1) {
return 65;
} else if (priority == 2) {
return 45;
} else if (priority == 3) {
return 25;
}
} else if (numTasks >= 50 && numTasks <= 124) {
if (priority == 1) {
return 70;
} else if (priority == 2) {
return 50;
} else if (priority == 3) {
return 30;
}
} else if (numTasks >= 125) {
if (priority == 1) {
return 85;
} else if (priority == 2) {
return 55;
} else if (priority == 3) {
return 35;
}
}
return 16;
}

public static void main(String[] args) {
int priority = 1;
int numTasks = 45;
int numPeople = findNumPeople(priority, numTasks);
System.out.println(numPeople);
}
}
```

In this program, the findNumPeople() method takes two integer parameters - priority and numTasks - and returns an integer representing the number of people required for the project. The method first checks the number of tasks to determine the appropriate range, and then checks the priority to return the corresponding number of people required based on the table provided in the problem statement. If the priority number is not in the table, the method returns 16.

In the main method, we call the findNumPeople() method with priority = 1 and numTasks = 45, and print the result to the console. This will output `65`, which is the correct number of people required for this project according to the table.
User Baskaya
by
8.3k points

No related questions found