-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTax.java
More file actions
executable file
·82 lines (66 loc) · 2.17 KB
/
Tax.java
File metadata and controls
executable file
·82 lines (66 loc) · 2.17 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* Tax class calculates the products' tax amount.
*
* @author Vanessa Esli Tovar
*/
public class Tax{
private float basicTaxRate;
private float importedTaxRate;
/**
* Construcor.
*
* @param basicTaxRate the desired basic sales tax rate
* @param importedTaxRate the desired imported tax rate
*/
public Tax(float basicTaxRate, float importedTaxRate){
this.basicTaxRate = basicTaxRate;
this.importedTaxRate = importedTaxRate;
}
/**
* Calculates the amount of tax that should be charged for this Product
*
* @param quantity amount of the same product user wishes to calculate the total tax for
* @param price price of the product user whishes to calculate tax for
* @param notExempt notExempt status of the product--if product is not exempt from the basic sales tax, then true
* @param imported imported status of the product--if product is imported, then true
*/
public float calcTax(int quantity, float price, boolean notExempt, boolean imported){
float totalPrice = quantity * price; // total price without tax
float totalTax = 0.0f;
if (notExempt)
totalTax += totalPrice * basicTaxRate;
if (imported)
totalTax += totalPrice * importedTaxRate;
return totalTax;
}
/**
* Getter method for the basic tax rate.
*/
public float getBasicTaxRate(){
return this.basicTaxRate;
}
/**
* Getter method for imported tax rate.
*/
public float getImportedTaxRate(){
return this.importedTaxRate;
}
/**
* Setter method for basic tax rate.
*
* @param basicTaxRate desired basic sales tax rate
*/
public void setBasicTaxRate(float basicTaxRate){
this.basicTaxRate = basicTaxRate;
}
/**
* Setter method for imported tax rate.
*
* @param importedTaxRate desired imported tax rate
*/
public void setImportedTaxRate(float importedTaxRate){
this.importedTaxRate = importedTaxRate;
}
public static void main(String[] args){
}
}