Task 1- Write a program that computes a single filer’s income tax burden. TAX RA
ID: 3572327 • Letter: T
Question
Task 1- Write a program that computes a single filer’s income tax burden.
TAX RATE
Single Filers Income
10%
Up to $6000
15%
$6,001 - $27,950
27%
$27,951 - $67,700
30%
$67,701 - $141,250
35%
$141,251 - $307,050
38.6%
$307, 051 or more
Object Orientated Design of Previous Problem
Create a set() method that will allow the user to input her income using new Scanner (System.in), input method and then a get() that will return the amount of tax owed.
All source code for solving the problem and handling user input should be created in a “programmer created class.”
Use return for retrieving all values from calculations and if/else statements etc.
main will be used to operate the program.
Output should have proper formatting for dollars, 2 decimal places.
Sample Output- //Output should have proper formatting for dollars, 2 decimal places
Income tax for a single person making $85000.00 is $25500.00
Income tax for a single person making $9800.00 is $1470.00
TAX RATE
Single Filers Income
10%
Up to $6000
15%
$6,001 - $27,950
27%
$27,951 - $67,700
30%
$67,701 - $141,250
35%
$141,251 - $307,050
38.6%
$307, 051 or more
Explanation / Answer
TaxCalc.java
import java.text.DecimalFormat;
import java.util.Scanner;
public class TaxCalc {
private static double income;
public static void main(String[] args) {
set();
DecimalFormat df = new DecimalFormat("0.00");
System.out.println("Income tax for a single person making $"+df.format(income)+" is $"+df.format(get()));
}
public static void set(){
Scanner scan = new Scanner (System.in);
System.out.println("Enter your income: ");
income = scan.nextDouble();
}
public static double get(){
double percentage = getTaxPercentage();
double tax = (percentage * income)/100;
return tax;
}
public static double getTaxPercentage(){
if(income <= 6000){
return 10;
}
else if(income > 6000 && income <=27950){
return 15;
}
else if(income > 27950 && income <=67700){
return 27;
}
else if(income > 67700 && income <=141250){
return 30;
}
else if(income > 141250 && income <=307050){
return 35;
}
else {
return 38.6;
}
}
}
Output:
Enter your income:
85000
Income tax for a single person making $85000.00 is $25500.00
Enter your income:
9800.00
Income tax for a single person making $9800.00 is $1470.00
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.