import java.text.DecimalFormat; import javax.swing.JOptionPane; import javax.swing.JTextArea; public class Week3 { public static void main(String[] args){ DecimalFormat df = new DecimalFormat("#,###,##0.00"); // set decimal format int Annual_Salary=Integer.parseInt(JOptionPane.showInputDialog("Enter Annual Salary ")), // annual salary Annual_Sales=Integer.parseInt(JOptionPane.showInputDialog("Enter Annual Annual_Sales ")), // Annual_Sales tar = 120000; // target Annual_Sales to reach JOptionPane.showMessageDialog(null,"Target Annual_Sales for this year are $120,000.00", "Annual Income", JOptionPane.INFORMATION_MESSAGE); double Total_Output = 0, //Total output Total_Commission = 0; // start array for total compensation table String outputx = " "; int last = (Annual_Sales*150)/100; // sets end of table to 50% above Annual_Sales double n[]; //declare reference to array double comrate = .05; // possible compensation rate double compensation = 0; // initialize compensation n = new double [last + 1]; // dynamically allocate array outputx += "Annual Annual_Sales\tAnnual Income\n"; // sets columns names for table //table starts Annual_Sales levels at $100,000.00 and increases Annual_Sales by $5,000.00 each row for (int i = Annual_Sales; i < n.length ; i = i + 5000){ compensation = i * comrate ; // compensation equals Annual_Sales level times Total_Commission rate n[i] = compensation + Annual_Salary; // displays compensation at each level of Annual_Sales if (i >= tar){ // accelerates Total_Commission for ever $5,000.00 above target comrate = comrate * 1.05; // at each level Total_Commission is increased by a multiplier of 1.03 } } // set table to display Annual_Sales levels and possible Total_Commission earned at each level for (int i = Annual_Sales; i < n.length ; i = i + 5000){ outputx = outputx + "$" + df.format(i) + "\t" + "$" + df.format(n[i]) + "\n"; }//end array for total compensation table if (Annual_Sales > (80 * tar)/100){ if (Annual_Sales < tar){ Total_Commission = Annual_Sales * .08; } else {Total_Commission = Annual_Sales * comrate; // Total_Commission earned } } Total_Output= Annual_Salary + Total_Commission; // salary plus Total_Commission //display actual annual income made JOptionPane.showMessageDialog(null,"Total Annual Income is $"+ df.format(Total_Output), "Annual Income", JOptionPane.INFORMATION_MESSAGE); // set area for array table to be displayed JTextArea outputArea = new JTextArea (11,10); outputArea.setText (outputx); // set window to display array table JOptionPane.showMessageDialog(null, outputArea, "Possible Annual Income",+ JOptionPane.INFORMATION_MESSAGE); } }