Here we’ll filter the list of tax names to show only those that are state taxes.
- Enter Code
Enter the following code in a file named ‘States.cs’:
using System;using System.Collections;using TaxControls;class Test{ public static void Main(){ try { CTaxControl tc = new CTaxControl(); tc.DataFilename = "demo.tax"; Taxes txs = tc.Taxes foreach(Tax t in txs) { if (t.TaxType == "S") { Console.WriteLine(t.Name); } } } catch (TaxControlException e) { Console.WriteLine(e.Message); } }}
Enter the following code in a file named ‘States.java’:
import com.boondocks.taxcontrols.TaxControl;import com.boondocks.taxcontrols.Taxes;import com.boondocks.taxcontrols.Tax;import com.boondocks.taxcontrols.TaxControlException;import java.util.Enumeration;public class States{ public static void main(String[] args){ TaxControl tc = new TaxControl(); tc.setDataFilename("demo.tax"); try{ for (Tax t: tc.getTaxes()) { if (t.getTaxType().equals("S")) { System.out.println(t.getName()); } } } catch (TaxControlException e){ e.printStackTrace(); } }}
- Compile
Compile the code at the command prompt by executing the following:
\...\csc.exe /reference:TaxControls.dll States.cs
javac -classpath .;bigloo_u.zip;TaxControls.jar States.java
- Run
Run the code by typing:
States
java -classpath .;bigloo_u.zip;TaxControls.jar States