/**
 * 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  Glen Newman
 * @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;
       
       //calculate the exemption - exemption is zero if value is negative
		 if (value < 0) exemption = 0;
		 else exemption = value * FOOD_EXEMPTION_RATE;
      
       //return the exemption
         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)
      {
			//salesTax is sales tax of value before food exemption
         double   exemption, salesTax, tax;
      	
      	//find exemption
         exemption = foodExemption(value);
			
			//find sales tax of food before 
			salesTax = salesTax(value);
			
			//calculate tax - take away exemption
			if (exemption > salesTax) tax = 0;
			else tax = salesTax - exemption;
       
         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;
       	
			//calcuate the sales tax
			//sales tax is zero if value is less than $0.20
			if (value < 0.2) tax = 0;
         else tax = value * SALES_TAX_RATE;       
               
         return tax;       
      }
   }
