-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAmontInTax.java
More file actions
38 lines (36 loc) · 1.16 KB
/
AmontInTax.java
File metadata and controls
38 lines (36 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<<<<<<< HEAD
//2303. Calculate Amount Paid in Taxes
class Solution {
public double calculateTax(int[][] brackets, int income) {
double tax = 0.0;
int prevUpper = 0;
for(int[] bracket : brackets){
int upper = bracket[0];
int percent = bracket[1];
int taxableAmount = Math.min(upper, income) - prevUpper;
if(taxableAmount <= 0) break;
tax += taxableAmount * (percent / 100.0);
prevUpper = upper;
if(income <= upper) break;
}
return tax;
}
=======
//2303. Calculate Amount Paid in Taxes
class Solution {
public double calculateTax(int[][] brackets, int income) {
double tax = 0.0;
int prevUpper = 0;
for(int[] bracket : brackets){
int upper = bracket[0];
int percent = bracket[1];
int taxableAmount = Math.min(upper, income) - prevUpper;
if(taxableAmount <= 0) break;
tax += taxableAmount * (percent / 100.0);
prevUpper = upper;
if(income <= upper) break;
}
return tax;
}
>>>>>>> be6ce0b427078b1421d5dd74adb2300dc02daeec
}