// X119SalesTax8Ver2 - Compute State and County Sales Tax on a Purchase. Using JOptionPane to get and display data

import javax.swing.JOptionPane; // Makes the JOptionPane avaialable for use

public class X119SalesTaxVer2
{
	public static void main(String[] args)
	{
		//Initialize variables

		final double cTaxRate = .02; // County Tax Rate

		final double sTaxRate = .04; // State Tax Rate

		double purchase; // Purchase amount

		double cSalesTax; // County sales tax paid

		double sSalesTax; // State sales tax paid

		double tSalesTax; // Total sales tax paid

		double tSale; // Amount of Total Sale

		String inputstring; // Variable for temporary storage of input data


		// Get Purchase amount from user and convert to Double from string

		inputstring = JOptionPane.showInputDialog("Please enter the purchase amount?");
		purchase = Double.parseDouble(inputstring);

		// Compute the amount of tax paid and total sale amount

		cSalesTax = purchase * cTaxRate;
		sSalesTax = purchase * sTaxRate;
		tSalesTax = cSalesTax + sSalesTax;
		tSale = tSalesTax + purchase;


		// Display resluts

		JOptionPane.showMessageDialog(null, "On a Purchase amount of $" + purchase + " the county sales tax is $" + cSalesTax +
		" the state sales tax is $" + sSalesTax + " for a total tax of $" + tSalesTax + " and a total sales amount of $" + tSale);

	}
}