配列を使用して納税者情報を保存するにはどうすればよいですか? 3 人の納税者の情報を入力したいとします。配列を使用して、名、姓、総収入などを 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);