Java Assignment
Java Assignment
MULTIMEDIA
SUPERVISOR: Mr.Foong
Design:
To address the difficulty for this assessment,
I used if-else statement. I've also
attached a flowchart of how
I fixed the problem.
Testing:
Test Description Expected Result Actual Result
ID
ID01 Testing of four filing Single = 0
statuses correctly Married filing joinly or Qualified widow= 1
displayed or not. Married filing separately= 2
Head of household= 3
ID02 The filing status 0 is Enter the filing status: 0
tested as specified in the Enter the taxable income: 100000
assessment, ensuring Tax is 21720.0
that the tax calculation
is properly coded. The
outcome should match
the predicted outcome.
ID03 The filing status 1 is Enter the filing status: 1
tested as specified in the Enter the taxable income: 300339
assessment, ensuring Tax is 76932.87
that the tax calculation
is properly coded. The
outcome should match
the predicted outcome.
ID04 The filing status 2 is Enter the filing status: 2
tested as specified in the Enter the taxable income: 123500
assessment, ensuring Tax is 29665.5
that the tax calculation
is properly coded. The
outcome should match
the predicted outcome.
ID05 The filing status 3 is Enter the filing status: 3
tested as specified in the Enter the taxable income: 4545402
assessment, ensuring Tax is 1565251
that the tax calculation
is properly coded. The
outcome should match
the predicted outcome.
ID06 Testing incorrect filing Invalid status Entered
status. When user
enters wrong filing
status it should prompt
invalid status entered.
Source code:
import java.util.Scanner;
public class TaxCalculator {
public static void main(String[] args) {
// Creating a Scanner
Scanner input = new Scanner(System.in);
// Assign Double
double tax = 0;
else
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
(82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
(372950 - 171550) * 0.33 + (income - 372950) * 0.35;
}
else
tax = 16700 * 0.10 + (67900 - 16700) * 0.15 +
(137050 - 67900) * 0.25 + (208850 - 137050) * 0.28 +
(372950 - 208850) * 0.33 + (income - 372950) * 0.35;
}
else
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
(68525 - 33950) * 0.25 + (104425 - 68525) * 0.28 +
(186475 - 104425) * 0.33 + (income - 186475) * 0.35;
}
else
tax = 11950 * 0.10 + (45500 - 11950) * 0.15 +
(117450 - 45500) * 0.25 + (190200 - 117450) * 0.28 +
(372950 - 190200) * 0.33 + (income - 372950) * 0.35;
}