I'm trying to make algorithm for optimization daily task schedule. For example:
1. There are 16 tasks to finish in one day, expirience worker can finish 8 tasks and newer worker could finish 4 tasks. As output we should get 2 expirienced worker and none new worker. For now I have this code, but it's not working properly:
private void calculate(int numberOfTasks, int oldWorkerValue, int youngWorkerValue) { int numberOfOldWorkers = numberOfTasks / oldWorkerValue; int numberOfYoungWorkers = 0; if(numberOfOldWorkers == 0) { numberOfOldWorkers = 1; } else { numberOfYoungWorkers = (numberOfTasks % numberOfOldWorkers) / youngWorkerValue; if(numberOfTasks % oldWorkerValue != youngWorkerValue*numberOfYoungWorkers) { numberOfYoungWorkers = numberOfYoungWorkers + 1; } } System.out.println("Expirienced worker: " + numberOfOldWorkers + " and new workers: " + numberOfYoungWorkers); } it returns me number of worker but it doesn't work like it should be. I don't get result like I wrote in this few examples. Could you give me some advice for this?
If there are 17 tasks, as output we should get 2 expirienced worker.this gives us 2*10 = 20, why can't we use 3 new workers, this will be only 18?