just need help with formatting a string to look like this:
Here is your tax breakdown:
Income $25,000.00
Dependants 1
----------------------------
Federal Tax $4,250.00
Provincial Tax $1,317.75
============================
Total Tax $5,567.75"
heres my code, please help me format as above with spaces and decimals
import java.util.Scanner;
public class HelloWorld {
public static void main(String args[]) {
double income, fedTax, provTax;
int dependents;
Scanner input = new Scanner(System.in);
System.out.print("Please enter your taxable income: ");
income = input.nextInt();
System.out.println();
System.out.print("Please enter your number of dependents: ");
dependents = input.nextInt();
System.out.println();
if (income <= 29590) {
fedTax = 0.17 * income;
}
else if (income <= 59179.99) {
fedTax = 0.17 * 29590 + 0.26 * (income - 29590);
}
else {
fedTax = 0.17 * 29590 + 0.26 * 29590 + (0.29 * (income - 59180));
}
double base = 42.5 * fedTax;
double deductions = 160.50 + 328 * dependents;
provTax = base - deductions;
if (base < deductions) {
provTax = 0;
}
else {
provTax = base - deductions;
}
double totalTax = fedTax + provTax;
System.out.println("Here is your tax breakdown: ");
System.out.println(String.format(" Income%,10.d", income));
System.out.println(String.format(" Dependants%10.d", dependents));
System.out.println("-------------------------");
System.out.println(String.format(" Federal Tax%,10.2f", fedTax));
System.out.println(String.format("Provincial tax%,10.2f", provTax));
System.out.println("=========================");
System.out.println(String.format(" Total Tax%,10.2f", totalTax));
}
}
please ignore down here this is just to let me post because there isnt enough words, even though my question does not to be detailed :(