/**
 * 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  Jake Carey
 * @version 1.0, September 16, 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)
      {
         double   exemption;
       
         exemption = 0.0;
      	
       //This if statement determines whether the value 
       // of the item is greater than 20 cents, thereby
       // determining whether it gets taxed or not.
         if (value >= 0.20)
         {
            exemption = FOOD_EXEMPTION_RATE * value;
         }//end if
         else if(value < 0.20)
         {
            exemption = 0.00;
         }//end else if
      
         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;
      
         tax = 0.0;
       
       //This calculates the total food tax by taking the
       // sales tax of the food and subtracting the food
       // exemption from its total value.
         if (value >= .20)
         {
            tax = (StateTaxes.salesTax(value)) -
				 (StateTaxes.foodExemption(value)); 
				 if (tax <= 0)
				 	tax = 0.00;
         }
         else if (value < .20)
         {
            tax = 0.00;
         }
         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;
       
         tax = 0.00;
       
       //This if statement determines whether the value 
       // of the item is greater than 20 cents, thereby
       // determining whether it gets taxed or not.
         if (value >= 0.20)
         {
            tax = SALES_TAX_RATE * value;
         }//end if
         else if(value < 0.20)
         {
            tax = 0.00;
         }//end else if
      
         return tax;       
      }//end salesTax
   }//end StateTaxes
