
/**
 * 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  Jeremy Halterman
 * @version 1.1
 * @date 9-16-08
 */

//public class
public class StateTaxesZ
{
	//variables accessible only to this class -- so the rates of tax cannot be changed
    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 exemption       The exemption (in dollars)
     */
    public static double foodExemption(double value)
    {
       //food exemption from sales tax variable
       double   exemption;
       
       exemption = 0.0; //initialized to 0
       
       		/*accepts a number that is the cost of a nonprep food item*/
       		if(value>0)
       		{
       			//calculates the tax credit
    	        exemption = FOOD_EXEMPTION_RATE * value;
       		
       		}//end if
       		else
       		    exemption = 0;
       /*returns back from the method the cost of cold food -- called within
        *LocalTaxes class for totaling a hot food item*/
       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 foodTax       The tax (in dollars)
     */
    public static double foodTax(double value)
    {
       //variable that holds the taxed result of nonprepared food items
       double   foodTax;
       foodTax = 0.0;//initialized to 0
        
       		//tax only applied if the cost of item is greater or equal to 20cents
       		if(value>=.20)
       		{
       			/*calculates tax by subtracting an exemption
       			 *if the exemption is applicable
       			 *the exemption is taken off of salesTax method*/
       			foodTax = salesTax(value) - foodExemption(value); 
       		
       		}//end if
       		
       		//returns no tax if the value of item is less than 20 cents
       		else
       			foodTax = 0.0;  	   
       
       /*returns foodTax method's value -- usually called within TaxCalculator for this
         particular usage*/
       return foodTax;       
    }//end foodTax method
    


    /**
     * Calculate the sales tax.
     *
     * @param value   The value of the items
     * @return salesTax       The tax (in dollars)
     */
    public static double salesTax(double value)
    {
       //variable for holding tax amount
       double    salesTax;
       salesTax = 0.00;//initialized variable  
       
       		//tax only applied if the cost of item is greater or equal to 20cents
       		if(value>=.20)
       		{
       			//base rate multiplied by passed value
       			salesTax = SALES_TAX_RATE * value;
       		
       		}//end if
       		
       		//used if value is less than 20cents
       		else
       			salesTax = 0.0;

       //returns salesTax -- used within TaxCalculator class
       return salesTax;       
    }//end salesTax method
}//end StateTaxes class
