/**
 * 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  Daniel Heck
 * @version 1.1	9/6/08
 */
public class StateTaxes
{
	//Constants representing different taxes or lack there of
    private static double FOOD_EXEMPTION_RATE = 0.02; //holds food exemption rate
    private static double SALES_TAX_RATE      = 0.05; //State sales tax rate
    private static double NO_SALES_TAX		  = 0.2;  //Constant for minimum price requirement

    /**
     * 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;
       
       //Multiply the item's value by the food exception
       exemption = FOOD_EXEMPTION_RATE * value;
       //If the exeception is less than zero set it to zero
       	if(exemption <  0.0)
       		exemption = 0.0;

       return exemption;	//Return the value * exemption for food tax
    }//end foodExemption method


    /**
     * 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)
    {
        //create local variable tax for holding finished tax and returning
        double   tax;
        
		//multipy the value using the SalesTax method then multiply the value
		//by using the foodExemption method and subtract the excemption from sales
		//tax setting it = to tax
       	tax = salesTax(value) - foodExemption(value);
       	//If the tax is < 0 tax is set to 0
        if(tax < 0)
        	tax = 0;	//set tax to zero if "if" statement is run
       
	   //Return finished tax       
       return tax;       
    }//end foodTax method

    /**
     * Calculate the sales tax.
     *
     * @param value   The value of the items
     * @return        The tax (in dollars)
     */
    public static double salesTax(double value)
    {
       double    tax; //declare local double tax
       
       //Tax may not be initialized, avoid error here
       tax = 0.00;
       //Do not calcualate sales tax unless value is > 20 cents
       if(value > .2)
       {
       	   tax = SALES_TAX_RATE * value;  //Multiply the item's value by the sales tax  
       }//end if

       return tax; //return the finalized tax value   
    }//end salesTax
}//end class
