Я работаю над школьным заданием, в котором пытаюсь рассчитать налоговую шкалу на основе того, что пользователь вводит в графический интерфейс.Я пытаюсь выяснить, как добавить текстовое поле в конце с результатами, но пока я могу только сделать out.println
.
import java.swing.JOptionPane;
public class GUI {
public static void main(String[] args) {
String fn = javax.swing.JOptionPane.showInputDialog("Enter house value");
int house = Integer.parseInt(fn);
double tax = 0;
if (house <= 8500)
tax = house * 0.10;
else if (house <= 34500)
tax = house * 0.15;
else if (house <= 83600)
tax = house * 0.25;
else if (house <= 174400)
tax = house * 0.28;
else if (house <= 379150)
tax = house * 0.33;
else if (house >= 379150)
tax = house * 0.35;
if (house <= 8500)
System.out.println("You have entered the 10% bracket. Due: $" + tax);
else if (house <= 34500)
System.out.println("You have entered the 15% bracket. Due: $"+ tax);
else if (house <= 83600)
System.out.println("You have entered the 25% bracket. Due: $"+ tax);
else if (house <= 174400)
System.out.println("You have entered the 28% bracket. Due: $"+ tax);
else if (house <= 379150)
System.out.println("You have entered the 33% bracket. Due: $"+ tax);
else if (house >= 379150)
System.out.println("You have entered the 35% bracket. Due: $"+ tax);
}
}