/**
 * 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  Glenn Young
 * @version 1.0  Date: September 12, 2008
 */
public class StateTaxes
{
    //constants set to the state food exemption rate
	 //and the sales tax rate
    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;
       
		 //the if block determines if the cost of the purchase
		 //is a positive value
		 if(value > 0.0)
		   //calculates the food exemption
       	exemption = FOOD_EXEMPTION_RATE*value;
		 else
		 	exemption = 0.0;


	    //return the value of the food exemption
       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;

       //if block confirms the cost is a positive amount
       if(value > 0.0)
		 {
		     //if block confirms that the sales tax is greater
			  //than or equal to the food exemption, and sets the 
			  //tax equal to zero if the exemption is greater
           if(salesTax(value) >= foodExemption(value))
			      //calculates the food tax
		         tax = (SALES_TAX_RATE - FOOD_EXEMPTION_RATE) * value;
		     else
		         tax = 0.0;
		 }//end if()
		 else
		     tax = 0.0;
       

       //returns the value of the food tax
       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;
       
		 //if block confirms the value of the purchase is
		 //at least 20 cents, otherwise sets the sales
		 //tax to zero
		 if(value >= 0.2)
           //calculates the sales tax
			  tax = SALES_TAX_RATE*value;    
	    else
		     tax = 0.0;   


       //return the value of the sales tax
       return tax;       
    }//end salesTax()
    


}//end StateTaxes
