/**
 * A utility class that can be used to calculate state taxes.
 *
 * In this case, there is a sales tax on all items but
 * (non-prepared) food has a special exemption.
 *
 *
 * This work complies with the JMU Honor Code.
 *
 * @author  Pan He	
 * @version 1.0  09/10/2008
 */
public class StateTaxes
{
    private static double FOOD_EXEMPTION_RATE = 0.02;
    private static double SALES_TAX_RATE      = 0.05;
    

    /**
     * Calculate the exemption on (non-prepared) food
     *
     * @param value   The value of the (non-prepared) food
     * @return        The exemption (in dollars)
     */
    public static double foodExemption(double value)
    {
       double   exemption;       
       exemption = 0.0;
       // if the value is below or equal to zero, the exemption always equals to 0.
       if(value <= 0)
    	   exemption = 0.0;
       else exemption = value * FOOD_EXEMPTION_RATE;
       return exemption;       
    }  // end foodExemption()


    /**
     * Calculate the tax on (non-prepared) food.
     *
     * The food tax is the sales tax less the food exemption.
     *
     * @param value   The value of the (non-prepared) food
     * @return        The tax (in dollars)
     */
    public static double foodTax(double value)
    {
       double   tax;
       tax = 0.0;
       /*
        *  if the exemption is greater than tax, there is no tax.
        *  otherwise the sales tax equals to tax minus exemption.
        */
       if((salesTax(value) - foodExemption(value)) <= 0)
    	   tax = 0.0;
       else tax = (salesTax(value) - foodExemption(value));
       return tax;           
    }  // end foodTax()
    


    /**
     * Calculate the sales tax.
     *
     * @param value   The value of the items
     * @return        The tax (in dollars)
     */
    public static double salesTax(double value)
    {
       double    tax;
       tax = 0.00;   
       // if the value is below to 0.2, there is not any tax to pay
       if(value < 0.2)
    	   tax = 0.0;
       else tax = value * SALES_TAX_RATE;       
       return tax; 
    }  // end saleTax()
    
}  // end class
