您好,我所在的班级需要将我的代码结果(计算联邦和州税)导出到文本文件中。我曾尝试四处浏览寻求帮助,但我似乎无法得到它。请帮忙!
public class FedStateTax {
public static void main(String[] args) {
String tn = javax.swing.JOptionPane.showInputDialog("Please enter your name.");
String fn = javax.swing.JOptionPane.showInputDialog("Enter income value");
int income = Integer.parseInt(fn);
double sax = 0;
double tax = 0;
if (income <= 50000)
tax = income * 0.10;
else if (income <= 100000)
tax = income * 0.15;
else if (income <= 150000)
tax = income * 0.20;
if (income <= 50000)
sax = income * 0.05;
else if (income <= 100000)
sax = income * 0.10;
else if (income <= 150000)
sax = income * 0.15;
if (income <= 50000)
System.out.println("Federal tax is: $" + tax);
else if (income <= 100000)
System.out.println("Federal tax is: $"+ tax);
else if (income <= 150000)
System.out.println("Federal tax is: $"+ tax);
if (income <= 50000)
System.out.println("State tax is: $" + sax);
else if (income <= 100000)
System.out.println("State tax is: $"+ tax);
else if (income <= 150000)
System.out.println("State tax is: $"+ tax);
}
}