/**
 * 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  Kurt Dowswell
 * @version 9/16/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;
       
			//calculate the non-prepared food exemption		 
         if (value > 0)
            exemption = value * FOOD_EXEMPTION_RATE;
         else
            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, taxCalc;
         double	 foodExemptionRate;
       
         //get food exemption rate
         foodExemptionRate = foodExemption(value);
			//get the sales tax for the price
         taxCalc = salesTax(value);
       
       	//check to see if exemption is greater than tax
			//then determine food tax
         if (foodExemptionRate > taxCalc)
            tax = 0;
         else
            tax = taxCalc - foodExemptionRate;
       	    
         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;
       
         //determine if taxable and calc sales tax
         if (value >= .2)
            tax = value * SALES_TAX_RATE; 
         else
            tax = 0;      
      
      
         return tax;       
      }//end salesTax
    
   }//end StateTaxes
