You MUST: use arrays to store taxpayer information. Use methods for tasks that will be repeated.
Ask the user how many taxpayers he would like to calculate taxes for.
Ask the user to enter each taxpayer's first name, last name gross income, and number of children.
Each taxpayer's tax due is computed as follows
The taxpayer's dependency exemption is determined by multiplying $3,000 times the number of children.
The taxpayer's net income is determined by taking the taxpayer's gross income and subtracting the taxpayer's dependency exemption.
If the taxpayer's net income is between 0 and 50,000, the tax due is 15% of net income.
If the taxpayer's net income is greater than 50,000, the tax due is
15% of the first 50,000 of net income PLUS
25% of any income over 50,000
The tax due can never be less than 0.
If the net income is a negative number, the tax due is 0
TAXPAYER INFORMATION: output a message in one dialog box which lists the following info for every taxpayer: first name, last name, gross income, number of children, tax due.
AVERAGE TAX: output a message in a dialog box which states the average of the taxes due.
PRESIDENTAL MESSAGE: output a message in a dialog box which says either "We computed taxes for the president. " or "We did not compute taxes for the president." The president's name is Barack Obama.
Here is my code so far
import javax.swing.JOptionPane; public class AssignmentSeven { public static void main (String [] args) { String [] taxPayers; String[] firstName; String [] lastName; String message = ""; double[] grossIncome; double [] netIncome; int children; int taxPayersSize; double dependencyExemption; double[] taxDue; taxPayersSize = Integer.parseInt (JOptionPane.showInputDialog (null, "How many tax payers do you want to calculate? ")); taxPayers = new String [taxPayersNumbers]; firstName = new String [taxPayersNumbers]; lastName = new String [taxPayersNumbers]; grossIncome = new double [taxPayersNumbers]; netIncome = new double [taxPayersNumbers]; taxDue = new double [taxPayersNumbers]; for (int i=0; i<taxPayers.length; i++) { firstName [i] = JOptionPane.showInputDialog (null, "What is your first name? "); lastName [i] = JOptionPane.showInputDialog (null, "What is your last name? "); grossIncome[i] = Double.parseDouble(JOptionPane.showInputDialog("What is your gross income? ")); children = Integer.parseInt(JOptionPane.showInputDialog(" How many children do you have? ")); dependencyExemption = 3000*children; netIncome [i] = grossIncome[i] - dependencyExemption; taxPayers[i] = "\n First name: " + firstName [i] + " \n Last name: " + lastName [i] + "\n Gross Income: " + grossIncome [i] + "\n Number of children: " + children; taxDue [i] = calculateTax (netIncome [i]); message += taxPayers[i] + "\n"; } JOptionPane.showMessageDialog (null,message); JOptionPane.showMessageDialog (null, "Hello, my name is Howard Deramus."); } public static double calculateTax (double [] theNetIncome) { double [] theTaxDue= new double [0]; double tax1 =0.15; double tax2 =0.25; for (int i= 0; i<theNetIncome.length; i++) { if (theNetIncome [i] > 50000) { theTaxDue[i] = (tax1*50000) + (tax2 *(theNetIncome[i]-50000)) ; } else if (theNetIncome[i] > 0) { theTaxDue[i] = (tax1*theNetIncome [i]); } else { theTaxDue [i] = 0; }//end else return theTaxDue [i]; } } }
And i get this error.
error: method calculateTax in class AssignmentSeven cannot be applied to given types;
taxDue [i] = calculateTax (netIncome [i]);
^
required: double[]
found: double
reason: actual argument double cannot be converted to double[] by method invocation conversion
1 error
Tool completed with exit code 1
Any help would be greatly appreciated. Thank you