/**
 * 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  Anthony Miles
 * @version 1.0
 */
public class StateTaxes
{
    private static final double FOOD_EXEMPTION_RATE = 0.02;
    private static final 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 )//If statement to check and make sure
		 					  //the value is not less than zero
							  //and if it is we set the exemption
							  //rate to 0;
			 exemption = value * FOOD_EXEMPTION_RATE;
		 else
		 	 exemption = value * 0;
		 
       return exemption;       
    }//end foodExemption


    /**
     * Calculate the tax on (non-prepared) food.
     *
     * The food tax is the sales tax minus 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( foodExemption(value) > salesTax(value) )
		 			//If statement to see if the exemption rate
					//is higher than the sales tax and if so
					//we set the tax to zero otherwise
					//we subtract the tax from the exemption
					//to get the total tax.
		 	tax = 0;
		 else
       	tax = salesTax(value) - foodExemption(value);   

       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( value < 0.2 ) //if statement to ensure no tax
		 						 //is applied if the total value
								 //is less than $0.20
		 	tax = value * 0;
		 else
       	tax = value * SALES_TAX_RATE;
       
       return tax;      
    }//end salesTax
    


}//end StateTaxes
