Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions income_tax.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*Question 5 Solution
*
*
*
*Group : Binary*/

import javax.swing.JOptionPane;

public class income_tax {

public static void main(String[] args) {

double taxIt = 1,taxed,after_tax = 0; //Declares and Initializes variables.


String input = JOptionPane.showInputDialog( " Enter Annual Salary(no spaces , numbers only) : "); //Prompts the employee to enter their annual salary.

double annual_salary = Double.parseDouble(input);

if (annual_salary <= 36000){
taxed = 0;
taxIt = 0;
after_tax = annual_salary - taxIt;
}

if ( 36000 < annual_salary && annual_salary <= 72000){
taxed = annual_salary - 36000;
taxIt = taxed * 0.05;
after_tax = annual_salary - taxIt;

}

if ( 72000 < annual_salary && annual_salary <= 108000){ //Checks the category the employee is in and then
taxed = annual_salary - 72000; //calculates the pre-tax,tax amount and salary post-tax.
taxIt = (taxed * 0.125) + 1800;
after_tax = annual_salary - taxIt;

}

if ( 108000 < annual_salary && annual_salary <= 144000){
taxed = annual_salary - 108000;
taxIt = (taxed * 0.1875) + 6300;
after_tax = annual_salary - taxIt;
}

if ( annual_salary > 144000){
taxed = annual_salary - 144000;
taxIt = (taxed * 0.25) + 13050;
after_tax = annual_salary - taxIt;
}
String message = String.format("Annual salary is : P%10.2f ", annual_salary ); //Displays the annual salary pre-tax.
String tmessage = String.format( "\n Annual Tax : P%10.2f", taxIt); //Displays the tax amount.
String smessage = String.format( "\n Annual Salary is : P%10.2f", after_tax); //Displays salary post-tax.

JOptionPane.showMessageDialog(null,message + tmessage + smessage);


}



}