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!!!

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);
}
}

Well, it seems like you're having some trouble with your program. Don't worry, I'm here to help. Let's break it down step by step.

First, we need to ask the user to enter the amount of their purchase. We can use the `Scanner` class to input the value. Here's the code for that:

```java
import java.util.Scanner;

public class SalesTaxCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.println("Enter the amount of the purchase: ");
double purchaseAmount = scanner.nextDouble();

// Rest of the code goes here

scanner.close();
}
}
```

Next, we need to compute the state and county sales tax. We know that the state sales tax is 4% and the county sales tax is 2%. We can calculate them using simple arithmetic. Here's the code for that:

```java
double stateSalesTax = purchaseAmount * 0.04;
double countySalesTax = purchaseAmount * 0.02;
```

Now, let's display the amount of the purchase, the state sales tax, the county sales tax, the total sales tax, and the total of the sale. Here's the code for that:

```java
System.out.println("Amount of purchase: $" + purchaseAmount);
System.out.println("State sales tax: $" + stateSalesTax);
System.out.println("County sales tax: $" + countySalesTax);
System.out.println("Total sales tax: $" + (stateSalesTax + countySalesTax));
System.out.println("Total sale: $" + (purchaseAmount + stateSalesTax + countySalesTax));
```

Finally, don't forget to close the `Scanner` object at the end of your program:

```java
scanner.close();
```

That's it! Now you should have a functioning program that calculates sales tax. Let me know if you need any further assistance, or if you have any more errors or questions.

Sure! I can help you with that. Here's a step-by-step guide to designing a program that calculates sales tax based on user input in Java:

Step 1: Import the required libraries.

```java
import java.util.Scanner;
```

Step 2: Create a `Scanner` object to read user input.

```java
Scanner scanner = new Scanner(System.in);
```

Step 3: Display a message to ask the user to enter the amount of the purchase.

```java
System.out.print("Enter the amount of the purchase: $");
```

Step 4: Read the user's input and store it in a variable.

```java
double purchaseAmount = scanner.nextDouble();
```

Step 5: Calculate the state and county sales tax.

```java
double stateSalesTax = purchaseAmount * 0.04;
double countySalesTax = purchaseAmount * 0.02;
```

Step 6: Calculate the total sales tax and the total sale.

```java
double totalSalesTax = stateSalesTax + countySalesTax;
double totalSale = purchaseAmount + totalSalesTax;
```

Step 7: Display the results.

```java
System.out.println("Amount of Purchase: $" + purchaseAmount);
System.out.println("State Sales Tax: $" + stateSalesTax);
System.out.println("County Sales Tax: $" + countySalesTax);
System.out.println("Total Sales Tax: $" + totalSalesTax);
System.out.println("Total Sale: $" + totalSale);
```

Step 8: Close the `Scanner` object.

```java
scanner.close();
```

That's it! The complete program should look like this:

```java
import java.util.Scanner;

public class SalesTaxCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.print("Enter the amount of the purchase: $");
double purchaseAmount = scanner.nextDouble();

double stateSalesTax = purchaseAmount * 0.04;
double countySalesTax = purchaseAmount * 0.02;

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

System.out.println("Amount of Purchase: $" + purchaseAmount);
System.out.println("State Sales Tax: $" + stateSalesTax);
System.out.println("County Sales Tax: $" + countySalesTax);
System.out.println("Total Sales Tax: $" + totalSalesTax);
System.out.println("Total Sale: $" + totalSale);

scanner.close();
}
}
```

I hope this helps! Let me know if you have any further questions.

Sure! I can help you with that. Let's break the problem down into smaller steps and explain how to solve them.

Step 1: Get the user input for the amount of the purchase.
To do this, you can use the Scanner class in Java to read user input from the console.

```java
import java.util.Scanner;

public class SalesTaxCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the amount of purchase: ");
double purchaseAmount = scanner.nextDouble();
scanner.close();

// Rest of the code will go here
}
}
```

Step 2: Calculate the state and county sales tax.
Given that the state sales tax is 4 percent and the county sales tax is 2 percent, you can calculate them as follows:

```java
double stateSalesTax = purchaseAmount * 0.04;
double countySalesTax = purchaseAmount * 0.02;
```

Step 3: Calculate the total sales tax and the total of the sale.
You can calculate the total sales tax by adding the state and county sales tax. The total of the sale can be calculated by adding the purchase amount to the total sales tax.

```java
double totalSalesTax = stateSalesTax + countySalesTax;
double totalSale = purchaseAmount + totalSalesTax;
```

Step 4: Display the results.
You can use the `System.out.println()` method to display the output to the user.

```java
System.out.println("Amount of Purchase: $" + purchaseAmount);
System.out.println("State Sales Tax: $" + stateSalesTax);
System.out.println("County Sales Tax: $" + countySalesTax);
System.out.println("Total Sales Tax: $" + totalSalesTax);
System.out.println("Total Sale: $" + totalSale);
```

Putting it all together, your final code should look like this:

```java
import java.util.Scanner;

public class SalesTaxCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the amount of purchase: ");
double purchaseAmount = scanner.nextDouble();
scanner.close();

double stateSalesTax = purchaseAmount * 0.04;
double countySalesTax = purchaseAmount * 0.02;
double totalSalesTax = stateSalesTax + countySalesTax;
double totalSale = purchaseAmount + totalSalesTax;

System.out.println("Amount of Purchase: $" + purchaseAmount);
System.out.println("State Sales Tax: $" + stateSalesTax);
System.out.println("County Sales Tax: $" + countySalesTax);
System.out.println("Total Sales Tax: $" + totalSalesTax);
System.out.println("Total Sale: $" + totalSale);
}
}
```

Now, when you run this program, it will prompt the user to enter the amount of the purchase and calculate the state and county sales tax, the total sales tax, and the total sale amount. It will then display the results to the user.

Make sure you have properly set up your project in NetBeans IDE and run this program inside a Java project. Let me know if you have any further questions or issues!