1 |
import javax.swing.JOptionPane; |
2 |
|
3 |
/** |
4 |
A class to test the TaxReturn class. |
5 |
*/ |
6 |
public class TaxReturnTest |
7 |
{ |
8 |
public static void main(String[] args) |
9 |
{ |
10 |
String input = JOptionPane.showInputDialog( |
11 |
"Please enter your income:"); |
12 |
double income = Double.parseDouble(input); |
13 |
|
14 |
input = JOptionPane.showInputDialog( |
15 |
"Please enter S (single) or M (married)"); |
16 |
int status = 0; |
17 |
|
18 |
if (input.equalsIgnoreCase("S")) |
19 |
status = TaxReturn.SINGLE; |
20 |
else if (input.equalsIgnoreCase("M")) |
21 |
status = TaxReturn.MARRIED; |
22 |
else |
23 |
{ |
24 |
System.out.println("Bad input."); |
25 |
System.exit(0); |
26 |
} |
27 |
|
28 |
TaxReturn aTaxReturn = new TaxReturn(income, status); |
29 |
|
30 |
System.out.println("The tax is " |
31 |
+ aTaxReturn.getTax()); |
32 |
|
33 |
System.exit(0); |
34 |
} |
35 |
} |