/**
 * 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:  Yanitsa Staleva
 * @version 1.0 date: 09/13/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;
		 
       if(value > 0)
       exemption = value*FOOD_EXEMPTION_RATE;
		 else
		 exemption = 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;
		 double   salesTax;
		 
		 salesTax = value*SALES_TAX_RATE;
		 
		 //The sales tax combinde with the food exemption.
		 //In the event that the food exemption exceeds the 
		 //sales tax on the total value of the food items 
		 //purchased the food tax is zero
		 
		 if(value < .20)
		 tax = 0;
		 else if(foodExemption(value) > salesTax)
		 tax = 0;
		 else
       tax = value* SALES_TAX_RATE - 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 value of the items purchase,
		//if the value is $.20 or more. It the 
		//value is less than $.20 then the sales tax is 0.
		
       double tax;
		 
		 if (value < .20)
		 tax = 0;
		 else
       tax = value*SALES_TAX_RATE;
		        
       return tax;       
    }
    
    }//StateTaxes
