Greetings all. I am having a problem with getting java program to produce the correct output. I am being asked to use conditional logic to determine a tax rate category. I am not getting any syntax errors at all but I am not getting the correct code after putting in the annual salary as directed.
Here is my code. Any help in pointing me in the right direction will be greatly appreciated.
import javax.swing.JOp tionPane;
public class TaxCodeTest1 {
public static void main(String[] args) {
float salary = 0;
float code = 0;
JOptionPane.sho wInputDialog(nu ll,
"Enter annual salary, example 10000",
"Input",
JOptionPane.QUE STION_MESSAGE);
if (salary < 15000) { //Salary less than 15000 code 1
code = '1';
JOptionPane.sho wMessageDialog( null, " Tax Code =" + 1);
}
else if (salary >= 15001 - 25000) { //salary between 15001 - 25000 code 2
code = '2';
JOptionPane.sho wMessageDialog( null, " Tax Code =" + 2);
}
else if (salary >= 25001 - 40000) { //salary between 25001 - 40000 code 3
code = '3';
}
else if (salary >= 40001 - 65000) { //salary between 40001 - 65000
code = '4';
}
else if (salary >= 65001 - 80000) { //salary between 65001 - 80000
code = '5';
}
else if (salary > 80000) { //salary greater than 80000
code = '6';
JOptionPane.sho wMessageDialog( null, "The code based on annual salary") ;
}
}
}
Here is my code. Any help in pointing me in the right direction will be greatly appreciated.
import javax.swing.JOp tionPane;
public class TaxCodeTest1 {
public static void main(String[] args) {
float salary = 0;
float code = 0;
JOptionPane.sho wInputDialog(nu ll,
"Enter annual salary, example 10000",
"Input",
JOptionPane.QUE STION_MESSAGE);
if (salary < 15000) { //Salary less than 15000 code 1
code = '1';
JOptionPane.sho wMessageDialog( null, " Tax Code =" + 1);
}
else if (salary >= 15001 - 25000) { //salary between 15001 - 25000 code 2
code = '2';
JOptionPane.sho wMessageDialog( null, " Tax Code =" + 2);
}
else if (salary >= 25001 - 40000) { //salary between 25001 - 40000 code 3
code = '3';
}
else if (salary >= 40001 - 65000) { //salary between 40001 - 65000
code = '4';
}
else if (salary >= 65001 - 80000) { //salary between 65001 - 80000
code = '5';
}
else if (salary > 80000) { //salary greater than 80000
code = '6';
JOptionPane.sho wMessageDialog( null, "The code based on annual salary") ;
}
}
}
Comment