Design a program that will ask the user to enter the amount of a purchase. The program should the compute the state and county sales tax. Assume the state sales tax is 4 percent and the county sales tax is 2 percent. The program should display the amount of the purchase, the state sales tax, the county sales tax, the total sales tax, and the total of the sale (which is the sum of the amount of purchase plus the total sales tax).

*I'm so lost. It gives me errors every time I attempt this on NetBeans IDE. Help!!!

1 answer

I used NetBeans IDE 7.1.2 and this worked:

package purchaseamount;

import java.util.Scanner;

/**
*
* @author AB
*/
public class PurchaseAmount {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
double purchaseAmount;
double stateSalesTax = 0.04;
double countySalesTax = 0.02;
double totalSalesTax;
double totalSale;

Scanner keyboard = new Scanner(System.in);
System.out.print("What is the purchase amount? ");
purchaseAmount = keyboard.nextDouble();



stateSalesTax = stateSalesTax * purchaseAmount;
countySalesTax = countySalesTax * purchaseAmount;
totalSalesTax = stateSalesTax * countySalesTax;
totalSale = totalSalesTax + purchaseAmount;

System.out.println("Purchase " + purchaseAmount);
System.out.println("State Tax " + stateSalesTax);
System.out.println("County Tax " + countySalesTax);
System.out.println("Total Tax " + totalSalesTax);
System.out.println("Total Sale " + totalSale);
}
}