/**
 * 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  Mark Koskinen
 * @version 1.0, Date: September 15, 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)
    {
	 
	 	 //Food Exemption: 2% of the (total) value of the (non-prepared) 
		 //food items being purchased (assuming the value is positive).
	 
       double   exemption;
		 exemption = 0;
		 if (value > 0) exemption = (value * FOOD_EXEMPTION_RATE); 
       return exemption;       
    }


    /**
     * 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)
    {
	 
	   //The sales tax combined with the food exemption.
		//[Note: The food tax is calculated using only the
		//(non-prepared) food items purchased, even if other items are
		//purchases at the same time.]
	 
	 
       double   tax;
		 if (foodExemption(value) > salesTax(value)) tax = 0;
		 else tax = salesTax(value)-foodExemption(value);
       return tax;       
    }
    


    /**
     * Calculate the sales tax.
     *
     * @param value   The value of the items
     * @return        The tax (in dollars)
     */
    public static double salesTax(double value)
    {
	 
		 //5% of the (total) value of the items purchased, 
		 //if the (total) value is $0.20 or more
		 
		 double    tax;
		 tax 		  = 0;
		 if (value >= .2)        tax = (value * SALES_TAX_RATE);
       return 	  tax;       
    }
    


}
