Skip to content

State tax names

Here we’ll filter the list of tax names to show only those that are state taxes.

  1. 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();
}
}
}
  1. Compile

Compile the code at the command prompt by executing the following:

Terminal window
\...\csc.exe /reference:TaxControls.dll States.cs
Terminal window
javac -classpath .;bigloo_u.zip;TaxControls.jar States.java
  1. Run

Run the code by typing:

Terminal window
States
Terminal window
java -classpath .;bigloo_u.zip;TaxControls.jar States