Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You have been asked to write a program to calculate income tax for a local Certi

ID: 3890630 • Letter: Y

Question

You have been asked to write a program to calculate income tax for a local Certified Public Accountant (CPA). You do not know how many customers will need to be served so your program will have to repeat the process until the last customer’s taxes have been calculated (use -1 for Customer ID to stop).

Input

Your program must take the following input:

Customer ID Number (int)

Total earnings for the year (double)

Federal taxes withheld (double)

State taxes withheld (double)

Amount of tax deductions (double)

Once you are confident your program runs, use the following dataset to run your program. Also, include three customers of your own.

Customer ID

Total Earnings

Federal Taxes W/H

State Taxes W/H

Deductions

101

$65,000

$12,000

$1,500

$5,000

102

$12,000

$2,100

$200

$3,000

103

$24,500

$2,000

$400

$0

104

$38,775

$8,965

$675

$2,575

105

$17,680

$2,350

$545

$1,300

Calculating Federal Tax

People who earn more money have to pay a higher percentage of their income to taxes. As a person’s income increases, there are transition points, called tax brackets, where additional taxes are paid. Assume the following tax brackets.

Income Bracket

Tax Rate (%)

$0 – 10,000

0%

$10,001 – 20,000

15%

$20,001 – 40,000

20%

Over $40,000

30%

If a person made $65,000 with $5,000 in deductions, the taxable income would be $60,000 ($65,000 - $5,000).   Federal taxes would look like this:

Income Bracket

Tax Rate (%)

Taxable Income ($)

Federal Taxes ($)

$0 – 10,000

0%

$10,000

$0

$10,001 – 20,000

15%

$10,000

$1,500

$20,001 – 40,000

20%

$20,000

$4,000

Over $40,000

30%

$20,000

$6,000

Total

$60,000

$11,500

Calculating State Tax

To calculate state income tax, simply multiply the total Federal taxes due ($11,500) by 7% ($805).

Calculating Refunds

To calculate refunds (or additional taxes due), subtract Federal taxes from Federal taxes withheld. Do the same for state taxes. A customer receiving a refund should have a positive value. Those owing additional taxes should be negative.

Must use this starter file:

public class TaxAccountant {
{
// declare variables
int customerID;
double totalEarnings = 0.0;
double federalTaxesWH = 0.0;
double stateTaxWH = 0.0;
double deductions = 0.0;
double taxableIncome = 0.0;
double federalTax = 0.0;
double stateRefund = 0.0;
double stateTax = 0.0;
double federalRefund = 0.0;

// Create a Scanner input object

// Begin first customer

// Get first Customer ID


while( )
{
// Get income and withholding information

// Calculate taxes due/refunds

// Add data to output String

// Get next Customer ID

}

// Print out table of data and end program


}
}

Customer ID

Total Earnings

Federal Taxes W/H

State Taxes W/H

Deductions

101

$65,000

$12,000

$1,500

$5,000

102

$12,000

$2,100

$200

$3,000

103

$24,500

$2,000

$400

$0

104

$38,775

$8,965

$675

$2,575

105

$17,680

$2,350

$545

$1,300

Explanation / Answer

Below is your code: -

import java.util.Scanner;

public class TaxAccountant {

public static void main(String[] args) {

// declare variables

int customerID;

double totalEarnings = 0.0;

double federalTaxesWH = 0.0;

double stateTaxWH = 0.0;

double deductions = 0.0;

double taxableIncome = 0.0;

double federalTax = 0.0;

double stateRefund = 0.0;

double stateTax = 0.0;

double federalRefund = 0.0;

// Create a Scanner input object

Scanner input = new Scanner(System.in);

String output = new String();

output += "Cust. Taxable Federal State Federal State Federal State ";

output += " ID Income Deductions Income Tax Tax W/H W/H Refund Refund ";

output += "===== ====== ========== ======= ======= ===== ======= ===== ======= ====== ";

// Begin first customer

// Get first Customer ID

System.out.println("Enter First Customer ID (-1 To Exit): ");

customerID = Integer.parseInt(input.next()) ;

boolean flag = false;

while (customerID != -1) {

flag = true;

System.out.print("Enter Total Earnings: ");

totalEarnings = input.nextDouble();

System.out.print("Enter Federal Taxes Withheld: ");

federalTaxesWH = input.nextDouble();

System.out.print("Enter State Taxes Withheld: ");

stateTaxWH = input.nextDouble();

System.out.print("Enter Deductions: ");

deductions = input.nextDouble();

// Calculate taxes due/refunds

taxableIncome = totalEarnings - deductions;

if (taxableIncome <= 10000.0) {

federalTax = 0.0;

} else

if (taxableIncome <= 20000.0) {

federalTax = (taxableIncome - 10000.0) * 0.15;

} else if (taxableIncome <= 40000.0) {

federalTax = (taxableIncome - 20000.0) * 0.2 + (0.15 * 10000.0);

} else if (taxableIncome > 40000.0) {

federalTax = (taxableIncome - 40000.0) * 0.3 + (0.2 * 20000.0);

}

stateTax = federalTax * 0.07;

federalRefund = federalTaxesWH - federalTax;

stateRefund = stateTaxWH - stateTax;

// Add data to output String

if (flag) {

output += String.format(

"%4d $%5.0f $%4.0f $%5.0f $%5.0f $%3.0f $%5.0f $%4.0f $%4.0f $%4.0f ",

customerID, totalEarnings, deductions, taxableIncome, federalTax, stateTax, federalTaxesWH,

stateTaxWH, federalRefund, stateRefund);

}

// Get next Customer ID

System.out.print("Enter the next Customer ID (-1 To Exit): ");

int custID = Integer.parseInt(input.next()) ;

if (custID == -1) {

flag = false;

break;

} else {

customerID = custID;

}

}

System.out.println();

// Print out table of data and end program

System.out.print(output);

}

}

Sample Run

Enter First Customer ID (-1 To Exit):
101
Enter Total Earnings: 65000
Enter Federal Taxes Withheld: 12000
Enter State Taxes Withheld: 1500
Enter Deductions: 5000
Enter the next Customer ID (-1 To Exit): 102
Enter Total Earnings: 12000
Enter Federal Taxes Withheld: 2100
Enter State Taxes Withheld: 200
Enter Deductions: 3000
Enter the next Customer ID (-1 To Exit): 103
Enter Total Earnings: 24500
Enter Federal Taxes Withheld: 2000
Enter State Taxes Withheld: 400
Enter Deductions: 0
Enter the next Customer ID (-1 To Exit): 104
Enter Total Earnings: 38775
Enter Federal Taxes Withheld: 8965
Enter State Taxes Withheld: 675
Enter Deductions: 2575
Enter the next Customer ID (-1 To Exit): 105
Enter Total Earnings: 17680
Enter Federal Taxes Withheld: 2350
Enter State Taxes Withheld: 545
Enter Deductions: 1300
Enter the next Customer ID (-1 To Exit): -1

Cust. Taxable Federal State Federal State Federal State
ID Income Deductions Income Tax Tax W/H W/H Refund Refund
===== ====== ========== ======= ======= ===== ======= ===== ======= ======
101 $65000 $5000 $60000 $10000 $700 $12000 $1500 $2000 $ 800
102 $12000 $3000 $ 9000 $ 0 $ 0 $ 2100 $ 200 $2100 $ 200
103 $24500 $ 0 $24500 $ 2400 $168 $ 2000 $ 400 $-400 $ 232
104 $38775 $2575 $36200 $ 4740 $332 $ 8965 $ 675 $4225 $ 343
105 $17680 $1300 $16380 $ 957 $ 67 $ 2350 $ 545 $1393 $ 478

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote