如何使用数组存储纳税人信息?假设我想输入 3 个纳税人的信息。如何使用数组将名字、姓氏、总收入等存储三遍?
numTaxpayers = Integer.parseInt(JOptionPane.showInputDialog("How many taxpayers would you like to calculate taxes for?"));
do
{
firstName = JOptionPane.showInputDialog("What is your first name?");
lastName = JOptionPane.showInputDialog("What is your last name?");
grossIncome = Double.parseDouble(JOptionPane.showInputDialog("What is your gross income?"));
numChildren = Integer.parseInt(JOptionPane.showInputDialog("How many children do you have?"));
taxDependency = numChildren * 3000;
taxableIncome = grossIncome - taxDependency;
name = firstName + " " + lastName;
tax = calculateTax(taxableIncome);
message += "First Name: " + firstName + "\nLast Name: " + lastName + "\nGross Income: $" + String.format("%.2f",grossIncome) + "\nNumber of Children: " + numChildren + "\nTax Due: $" + String.format("%.2f",tax) + "\n\n";
count ++;
} while (count <= numTaxpayers);
JOptionPane.showMessageDialog(null,message);