Answer:
- import java.util.Scanner;
-
- public class Main {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.print("Input total sales of month: ");
- double totalSales = input.nextDouble();
-
- double stateTax = totalSales * 0.04;
- double countyTax = totalSales * 0.02;
- double totalSalesTax = stateTax + countyTax;
-
- System.out.println("County Tax: $" + countyTax);
- System.out.println("State Tax: $" + stateTax);
- System.out.println("Total Sales Tax: $" + totalSalesTax);
- }
- }
Step-by-step explanation:
Firstly, create a Scanner object and prompt user to input total sales of month (Line 5-7). Next, apply the appropriate tax rate to calculate the state tax, county tax (Line 9 - 10). Total up the state tax and county tax to get the total sales tax (Line 11).
At last, print the county tax, state tax and the total sales tax (Line 13 - 15).