I'm a beginner to Java and I need to know how to do the following:

Write a program that will ask the user to enter the amount of a purchase. The program should then 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). Hint: Use the value 0.02 to represent 2 percent, and 0.04 to represent 4 percent.

Can anybody help me?

// Create a Scanner object to read input.

Scanner keyboard = new Scanner(System.in);

// Get the Purchase Amount
System.out.print(" What is the Purchase Amount?");
purchaseAmount=keyboard.nextDouble( );

stateSalesTax=0.04*purchaseAmount;
countySalesTax=0.02*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 +"\n_________");
System.out.println( " Total Sale " + totalSale);

}
}

Post either pseudocode, or actual coding, in whatever shape they are in.

If you do not know how to do either one of the two, post what you have learned, the name of your textbook, the chapters covered, and the course outline.

A customer is in a store to purchase 6 items. Write a program which asks for the sales tax and the price of each item, then displays: 1. the subtotal of the sale 2. the total amount of tax to be collected 3. the total amount the customer must pay

Of course! I can help you with that. To write a program that calculates the sales tax and total sale amount, you can follow these steps:

1. Import the necessary Java classes for user input and decimal formatting. You can use the `Scanner` and `DecimalFormat` classes.

```java
import java.util.Scanner;
import java.text.DecimalFormat;
```

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

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

3. Prompt the user to enter the amount of the purchase and store it in a variable.

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

4. Calculate the state and county sales tax by multiplying the purchase amount by the corresponding tax rate.

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

5. Calculate the total sales tax by summing the state and county sales tax.

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

6. Calculate the total sale amount by adding the purchase amount and the total sales tax.

```java
double totalSaleAmount = purchaseAmount + totalSalesTax;
```

7. Create a `DecimalFormat` object to format the output in a desired format, such as currency format.

```java
DecimalFormat decimalFormat = new DecimalFormat("#0.00");
```

8. Display the results to the user using the formatted values.

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

9. Finally, close the `Scanner` object to prevent resource leaks.

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

Here's the complete code:

```java
import java.util.Scanner;
import java.text.DecimalFormat;

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

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

DecimalFormat decimalFormat = new DecimalFormat("#0.00");

System.out.println("Amount of purchase: $" + decimalFormat.format(purchaseAmount));
System.out.println("State sales tax: $" + decimalFormat.format(stateSalesTax));
System.out.println("County sales tax: $" + decimalFormat.format(countySalesTax));
System.out.println("Total sales tax: $" + decimalFormat.format(totalSalesTax));
System.out.println("Total sale amount: $" + decimalFormat.format(totalSaleAmount));

scanner.close();
}
}
```

This program will prompt the user to enter the purchase amount, calculate the sales tax using the given tax rates, and display all the values you mentioned.