import javax.swing.JOptionPane; public class If1 { public void driving() { String response = ""; String ageStr = JOptionPane.showInputDialog("How old are you?"); int age = Integer.parseInt(ageStr); if (age >= 18) response = "You can get a full driver's license."; else if (age == 17) response = "You can get a provisional license."; else if (age == 16) response = "You can get a learner's permit."; else response = "You need to be older to drive a car."; JOptionPane.showMessageDialog(null, response); } public static void main(String[] args) { If1 if1 = new If1(); String incomeStr = JOptionPane.showInputDialog("Income: "); double income = Double.parseDouble(incomeStr); boolean single = true; String singleStr = JOptionPane.showInputDialog("Single: (y/n)"); if (singleStr.equals("y")) single = true; else single = false; double tax = if1.taxes(income,single); String msg = "With income of $" + income + " tax is $" + tax; JOptionPane.showMessageDialog(null, msg); } public double taxes(double income, boolean single) { double RATE1_SINGLE_LIMIT = 32000; double RATE1_MARRIED_LIMIT = 64000; double tax1 = 0, tax2 = 0; if (single) { if (income <= RATE1_SINGLE_LIMIT) { tax1 = 0.10 * income; } else; { tax1 = 0.10 * RATE1_SINGLE_LIMIT; tax2 = 0.25 * (income - RATE1_SINGLE_LIMIT); } } else { if (income <= RATE1_MARRIED_LIMIT) tax1 = 0.10 * income; else { tax1 = 0.10 * RATE1_MARRIED_LIMIT; tax2 = 0.25 * (income - RATE1_MARRIED_LIMIT); } } return tax1 + tax2; } }