-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTax.java
More file actions
44 lines (35 loc) · 1.11 KB
/
Copy pathTax.java
File metadata and controls
44 lines (35 loc) · 1.11 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
39
40
41
42
43
44
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
public class Tax {
// tax percentage rates
private static double basicSalesTaxRate = 0.10;
private static double importDutyRate = 0.05;
// an array list for the exemptions
private static ArrayList<String> exemptionList = new ArrayList<String>();
// set the exemptions
public static void setExemptionList() throws FileNotFoundException {
Scanner exemptionInput = new Scanner(new File("../exemptions.txt"));
while (exemptionInput.hasNextLine()) {
String exemption = exemptionInput.nextLine();
exemptionList.add(exemption);
}
}
// get the exemptions
public static ArrayList<String> getExemptionList() {
return exemptionList;
}
// basic sales tax formula
public static double basicSalesTax(double price) {
return rounded(price * basicSalesTaxRate);
}
// import duty formula
public static double importDuty(double price) {
return rounded(price * importDutyRate);
}
// rounding to nearest .05
private static double rounded(double tax) {
return (Math.ceil((tax) * 20) / 20);
}
}