diff options
| author | Ali <adeadmarshal@gmail.com> | 2025-05-26 16:56:02 +0330 |
|---|---|---|
| committer | Ali <adeadmarshal@gmail.com> | 2025-05-26 16:56:02 +0330 |
| commit | 9e6e9e5f067367edabd91501eb9b94014a40f9f2 (patch) | |
| tree | 365940c0caf3bb367a330f021fe1a80f15556df2 /challenge-323/deadmarshal/java/Ch2.java | |
| parent | 0729d1308bfe2e7d4fc1ea6f41b40356645d4f72 (diff) | |
| download | perlweeklychallenge-club-9e6e9e5f067367edabd91501eb9b94014a40f9f2.tar.gz perlweeklychallenge-club-9e6e9e5f067367edabd91501eb9b94014a40f9f2.tar.bz2 perlweeklychallenge-club-9e6e9e5f067367edabd91501eb9b94014a40f9f2.zip | |
TWC323
Diffstat (limited to 'challenge-323/deadmarshal/java/Ch2.java')
| -rw-r--r-- | challenge-323/deadmarshal/java/Ch2.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/challenge-323/deadmarshal/java/Ch2.java b/challenge-323/deadmarshal/java/Ch2.java new file mode 100644 index 0000000000..b2208c1d23 --- /dev/null +++ b/challenge-323/deadmarshal/java/Ch2.java @@ -0,0 +1,17 @@ +public class Ch2 { + public static void main(String[] args) { + System.out.println(tax_amount(10, new int[][]{{3, 50}, {7, 10}, {12, 25}})); + System.out.println(tax_amount(2, new int[][]{{1, 0}, {4, 25}, {5, 50}})); + System.out.println(tax_amount(0, new int[][]{{2, 50}})); + } + + private static double tax_amount(int income, int[][] taxes) { + int res = 0, prev = 0; + for (var e : taxes) { + res += Math.max(0, Math.min(income, e[0]) - prev) * e[1]; + prev = e[0]; + } + return res / 100.0; + } +} + |
