Respuesta :
Answer:
// Scanner class is imported to allow program receive user input
import java.util.Scanner;
// Solution is defined
public class Solution {
// main method is defined to begin program execution
public static void main(String args[]) {
// A welcome message is displayed to user
System.out.println("Welcome to the total tax calculator program");
// inputData is called and assigned to total_sales
int total_sales = inputData();
// calcCounty is called and assigned to county_tax
double county_tax = calcCounty(total_sales);
// calcState is called and assigned to state_tax
double state_tax = calcState(total_sales);
// calcTotal is called and assigned to total_tax
double total_tax = calcTotal(state_tax, county_tax);
// printData is called
printData(state_tax, county_tax, total_tax);
}
// The inputData method receive input from user
// The method returns the received input
public static int inputData(){
// A scan object is defined to received input
Scanner scan = new Scanner(System.in);
System.out.print("Enter the total sales for the month $");
int entered_total = scan.nextInt();
return entered_total;
}
// The calcCounty method is defined and it
// return the county_tax
public static double calcCounty(double total_sales){
double county_tax = 0.02 * total_sales;
return county_tax;
}
// The calcState method is defined and it
// return the state_tax
public static double calcState(double total_sales){
double state_tax = 0.04 * total_sales;
return state_tax;
}
// The calcTotal method is defined and it
// return the total_tax
public static double calcTotal(double state_tax, double county_tax){
double total_tax = state_tax + county_tax;
return total_tax;
}
// The printData method print out the data
// Each data is displayed to 2 decimal place
public static void printData(double state_tax, double county_tax, double total_tax){
System.out.println("The county tax is $" + String.format("%.2f", county_tax));
System.out.println("The state tax is $" + String.format("%.2f", state_tax));
System.out.println("The total tax is $" + String.format("%.2f", total_tax));
}
}
Explanation: