/**
 * 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  DAT NGUYEN
 * @version 1.0
 */
public class StateTaxes
{
	//class static variables
	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)
	{
		//local variable
		double   exemption;
    	
		//initialze variable
      	exemption = 0.0;
		
		//calculation the exemption on non_prepared food
      	exemption = value * FOOD_EXEMPTION_RATE;
		
		//return the exemption value
      	return exemption;       
   	} //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)
	{
		//local variable
		double   tax;

		//initialize variable
		tax = 0.0;
       
		//if-else condition to check and calculae the tax on 
		//non-prepared food
		if (foodExemption(value) > salesTax(value))
			tax = 0;
		else  
			tax = salesTax(value) - foodExemption(value);
       
		//return the tax value
		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)
	{		
		//local variable
		double    tax;
       
		//initialize variable
		tax = 0.00;       
		
		//if-else condition to check and calculate the 
		//sales tax 
		if(value > 0.20)
			tax = value * SALES_TAX_RATE;
		else
			tax = 0.0;

		//returns the tax value
		return tax;       
	} //end salesTax method
} //end class
