/**
 * 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  Hunter McMillen
 * @version 1.0 - 9/8/08
 */
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;
       
       //check to see if the value is greater than zero
       if(value > 0)
       {
           exemption = value * FOOD_EXEMPTION_RATE;
       }
       else //if negative argument is passed exemption is zero
       {
           exemption = 0;
       }
       
       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;
       
       //check to see if the value is positive and 
       //checks to see if its sales tax is positive
       //ensures you dont get a negative result
       if(value > 0 && salesTax(value) != 0)
       {
           tax = (salesTax(value) - foodExemption(value));
       }
       else //if not positive exemption is 0
       {
           tax = 0;
       }
       
       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;
       
       //checks to see if value is positive and greater than 20 cents
       if(value >= .20 && value > 0)
       {
           tax = value * SALES_TAX_RATE;
       }
       else //if either condition is false tax is 0
       {
           tax = 0;
       }
             
       return tax;       
    }//end salesTax
}//end StateTaxes
