/**
 * 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 Micheal Cottingham
 * @version 1.0 - 9/18/2008
 */
public class StateTaxes
{
    // These constants are needed for the exemption
	 // and sales tax rate
	 // No magic numbers!
    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;

       // The exemption on non-prepared food is defined as
		 // 2% of the total value of the non-prepared food items
		 // being purchased

       // If value is less than or equal to 0, we
		 // shouldn't try to calculate the exemption
		 if(value <= 0)
		 {
		    exemption = 0.00;
		 }

       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;

       if(foodExemption(value) > salesTax(value))
		 {
		     tax = 0.00;
		 }

       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;

       // Determine if the value is equal to or over 20 cents
       if(value >= .2)
		 {
		    // If it is, we take the rate times the value
			 // to get the actual tax
		    tax = value * SALES_TAX_RATE;
		 }

       else
		 {
		    // If it is not, then no tax is
			 // applied
          tax = 0.00;
		 }

       return tax;       
    } // end salesTax
} // end class