/**
 * 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  Cory McDaniel
 * @version 1.1
 */
public class StateTaxes
{
    private static double FOOD_EXEMPTION_RATE = 0.02;
    private static double FOOD_TAX_RATE      = 0.05;
    private static double SALES_TAX_RATE      = 0.05;
    
    /**
     * Calculates 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;
       
       if (value > 0.00)  //in case the user input is wrong and they enter a negative
    	   exemption = 0.02*value;
       else
    	   exemption = 0.00;

       return exemption;       
    }

    /**
     * Calculates 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 (value * 0.05 > value * 0.020 &&  value >= 0.20)
    	   //only applies the tax if the foodExemption is greater 
    	   //than the sales tax and the items value is 0.20 or more
    	   tax = value * 0.05 - value * 0.02;
       else
    	   tax = 0.00;
           
       return tax;       
    }
  
    /**
     * Calculates the sales tax.
     *
     * @param value   The value of the items
     * @return        The tax (in dollars)
     */
    public static double salesTax(double value)
    {
       double    tax;
       
       if (value >= 0.20)
    	   //only occurs when the value of the item 
    	   //purchased is 0.20 or more
    	   tax = value * 0.05;
       else 
    	   tax = 0.0;      

       return tax;       
    }
    
}
