In: Computer Science
Problem 1 The United States Federal Income tax for taxes due July 15, 2020 is available at this link: https://www.bankrate.com/finance/taxes/tax-brackets.aspx The four tax filing categories are: 0 - single filer, 2 - head of household, 3 - married filing jointly or qualifying widow, and 4 - married filing seperately. Write a Java program that prompts the user to enter the name, filing status, and annual income. The program returns the federal income tax due. (10 Points) A sample run should look like: Enter your name: Jane Doe Enter your 2019 federal income: 48,000 Enter your filing status: single Jane Doe, the federal income tax for an annual salary of 48,000 for a single filer is $4,800. Draw a UML diagram for the class. You may use Astah tool. (5 points). Submit both the java code and UML diagram. *
Here is the Java code:
import java.util.Scanner;
public class USFederal{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.print("Enter your name: ");
String name = scan.nextLine();
System.out.print("Enter your 2019 federal income: ");
int income = scan.nextInt();
System.out.print("Enter your filing status: ");
String status = scan.next();
int tax=0;
if(status.equals("single")){
if(income>=0 && income<=9750){
tax = 10;
}
if(income>=9701 && income<=39475){
tax = 12;
}
if(income>=39476 && income<=82200){
tax = 22;
}
if(income>=82201 && income<=160725){
tax = 24;
}
if(income>=160726 && income<=204100){
tax = 32;
}
if(income>=204101 && income<=510300){
tax = 35;
}
if(income>=510301){
tax = 37;
}
}
if(status.equals("head")){
if(income>=0 && income<=13850){
tax = 10;
}
if(income>=13851 && income<=52850){
tax = 12;
}
if(income>=52851 && income<=84200){
tax = 22;
}
if(income>=84201 && income<=160700){
tax = 24;
}
if(income>=160701 && income<=204100){
tax = 32;
}
if(income>=204101 && income<=510300){
tax = 35;
}
if(income>=510301){
tax = 37;
}
}
if(status.equals("married filing jointly")){
if(income>=0 && income<=19400){
tax = 10;
}
if(income>=19401 && income<=78950){
tax = 12;
}
if(income>=78951 && income<=168400){
tax = 22;
}
if(income>=168401 && income<=321450){
tax = 24;
}
if(income>=321451 && income<=408200){
tax = 32;
}
if(income>=408201 && income<=612350){
tax = 35;
}
if(income>=612351){
tax = 37;
}
}
if(status.equals("married filing separately")){
if(income>=0 && income<=9700){
tax = 10;
}
if(income>=9701 && income<=39475){
tax = 12;
}
if(income>=39476 && income<=84200){
tax = 22;
}
if(income>=84201 && income<=160725){
tax = 24;
}
if(income>=160726 && income<=204100){
tax = 32;
}
if(income>=204101 && income<=306175){
tax = 35;
}
if(income>=306176){
tax = 37;
}
}
tax = (income/100)*tax;
System.out.println("\n"+name+", the federal income tax for an annual salary of "+income+" for a "+status+" filer is "+tax);
}
}
Output:
UML: