Drill

ProblemsJava › machines

Finished units in a shift

mediummachinesMathJava

A production planner works out how much good product a shift turns out: run time at a rate, less scrap.

shiftOutput(perHour: int, shiftMinutes: int, breakMinutes: int, scrapPercent: int) → int

Java needs a compiler and Drill does not host one yet, so this page is the reference rather than an exercise: the problem, worked examples, and the solution in full. To type it out, the same problem runs in Python.

Solve it in Python →

Where you start

int shiftOutput(int perHour, int shiftMinutes, int breakMinutes, int scrapPercent) {
    
}

Worked examples

CallResult
shiftOutput(360, 480, 30, 10)2430
shiftOutput(60, 120, 0, 0)120
shiftOutput(360, 480, 480, 0)0
shiftOutput(60, 390, 30, 25)270

Hint

Do the truncation at each step: first production, then finished.

Reference solution in Java
int shiftOutput(int perHour, int shiftMinutes, int breakMinutes, int scrapPercent) {
    int production = ((shiftMinutes - breakMinutes) * perHour) / 60;
    return (production * (100 - scrapPercent)) / 100;
}

The same problem in another language

More machines problems in Java