/**
 * 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  Ryan Johnson
 * @version 1.0
 */
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;
      
		 // food exemption is 2% of the value of non-prepared food items
       
		 if (value > 0)
		 {
		 		exemption = FOOD_EXEMPTION_RATE * value;			
		 }
		 else
		 {
		 		exemption = 0.0;
		 }
		 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)
    {
       double   tax;
       
      
		 // If food exemption exceeds the sales tax on the total value 
		 // of the (non-prepared) food items purchased, the food tax is zero

		 if (foodExemption(value) > salesTax(value))
		 {
		 		tax = 0.0;
		 }
		 else
		 {
		 		// The sales tax combined with the food exemption	
				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)
    {
       double    tax;
       
       if (value >= 0.20)
		 {
		 		tax = SALES_TAX_RATE * value;
		 }
		 else
		 {
		 		// If the total value is less than $0.20
				// then the tax is zero	
				tax = 0.0;
		 }       

		 return tax;       
    }
    


}
