/******************************************************************** * * * * * A JAVA PROGRAM TO CALCULATE AIR FORCE RESERVE RETIREMENT * * * * * * IKE 15 Jan 08 (Based on 1 Apr 07 Pay Charts) * * * ********************************************************************/ import java.awt.*; import java.applet.*; import javax.swing.*; import java.awt.event.*; public class Retirement07 extends JApplet { private Container c; private JComboBox CompList; private JComboBox YearList; String rankList[ ] = {"General", "Lieutenant General", "Major General", "Brigadier General", "Colonel", "Lieutenant Colonel", "Major", "Captain ", "First Lieutenant", "Second Lieutenant", "* Captain *", "* First Lieutenant *", "* Second Lieutenant *", "Chief Master Sergeant", "Senior Master Sergeant", "Master Sergeant", "Technical Sergeant", "Staff Sergeant", "Senior Airman" }; String yearsList[ ] = {"Over 20", "Over 22", "Over 24", "Over 26", "Over 28", "Over 30", "Over 32", "Over 34", "Over 36", "Over 38", "Over 40"}; //20 Years double payList[ ] = { 0.94854, 0.82963, 0.78604, 0.71083, 0.56806, 0.49708, 0.43419, 0.37194, 0.27338, 0.21573, 0.39694, 0.31658, 0.26788, 0.33483, 0.28898, 0.25804, 0.21760, 0.18265, 0.14325 }; //22 Years double payList1[ ] = { 0.95319, 0.84156, 0.80544, 0.71083, 0.58300, 0.51202, 0.43419, 0.37194, 0.27338, 0.21573, 0.39694, 0.31658, 0.26788, 0.34794, 0.30190, 0.26750, 0.21760, 0.18265, 0.14325 }; //24 Years double payList2[ ] = { 0.97300, 0.85883, 0.80544, 0.71083, 0.59813, 0.51202, 0.43419, 0.37194, 0.27338, 0.21573, 0.39694, 0.31658, 0.26788, 0.36175, 0.30906, 0.27258, 0.21760, 0.18265, 0.14325 }; //26 Years double payList3[ ] = { 1.00754, 0.88898, 0.80544, 0.71444, 0.62748, 0.51202, 0.43419, 0.37194, 0.27338, 0.21573, 0.39694, 0.31658, 0.26788, 0.38283, 0.32673, 0.29196, 0.21760, 0.18265, 0.14325 }; //28 Years double payList4[ ] = { 1.00754, 0.88898, 0.80544, 0.71444, 0.62748, 0.51202, 0.43419, 0.37194, 0.27338, 0.21573, 0.39694, 0.31658, 0.26788, 0.38283, 0.32673, 0.29196, 0.21760, 0.18265, 0.14325 }; //30 Years double payList5[ ] = { 1.05792, 0.93344, 0.82558, 0.72873, 0.64002, 0.51202, 0.43419, 0.37194, 0.27338, 0.21573, 0.39694, 0.31658, 0.26788, 0.40198, 0.33327, 0.29196, 0.21760, 0.18265, 0.14325 }; //32 Years double payList6[ ] = { 1.05792, 0.93344, 0.82558, 0.72873, 0.64002, 0.51202, 0.43419, 0.37194, 0.27338, 0.21573, 0.39694, 0.31658, 0.26788, 0.40198, 0.33327, 0.29196, 0.21760, 0.18265, 0.14325 }; //34 Years double payList7[ ] = { 1.11081, 0.98010, 0.84623, 0.72873, 0.64002, 0.51202, 0.43419, 0.37194, 0.27338, 0.21573, 0.39694, 0.31658, 0.26788, 0.42208, 0.33327, 0.29196, 0.21760, 0.18265, 0.14325 }; //36 Years double payList8[ ] = { 1.11081, 0.98010, 0.84623, 0.72873, 0.64002, 0.51202, 0.43419, 0.37194, 0.27338, 0.21573, 0.39694, 0.31658, 0.26788, 0.42208, 0.33327, 0.29196, 0.21760, 0.18265, 0.14325 }; //38 Years double payList9[ ] = { 1.16635, 1.02910, 0.84623, 0.72873, 0.64002, 0.51202, 0.43419, 0.37194, 0.27338, 0.21573, 0.39694, 0.31658, 0.26788, 0.44319, 0.33327, 0.29196, 0.21760, 0.18265, 0.14325 }; //40 Years double payList10[ ] = { 1.16635, 1.02910, 0.84623, 0.72873, 0.64002, 0.51202, 0.43419, 0.37194, 0.27338, 0.21573, 0.39694, 0.31658, 0.26788, 0.44319, 0.33327, 0.29196, 0.21760, 0.18265, 0.14325 }; private JLabel quant, rank, year, output, fourpay, blank; private JTextField quantity; private JTextArea outputArea; private JButton button1; private JPanel panel1; public void init() { Container c = getContentPane(); c.setLayout(new FlowLayout()); rank = new JLabel("Rank"); c.add(rank); CompList = new JComboBox(rankList); c.add(CompList); year = new JLabel("Years "); c.add(year); YearList = new JComboBox(yearsList); c.add(YearList); panel1 = new JPanel(); quant = new JLabel("Enter # of Points:"); panel1.add(quant); quantity = new JTextField(5); panel1.add(quantity); c.add(panel1); button1 = new JButton("OK"); c.add(button1); ButtonHandler handler = new ButtonHandler(); button1.addActionListener(handler); //this output = new JLabel("Monthly Retirement Estimate:"); c.add(output); outputArea = new JTextArea(1,15); c.add(outputArea); blank = new JLabel (" __________________________________________________________ "); c.add(blank); fourpay = new JLabel(" * over four years of enlisted service "); c.add(fourpay); setSize(360,140); } private class ButtonHandler implements ActionListener { public void actionPerformed (ActionEvent e) { buildOutput(); } } public void buildOutput() { int compIndex = CompList.getSelectedIndex(); //getting the index int yearIndex = YearList.getSelectedIndex(); //I added this if (yearIndex == 0) { double price = payList[compIndex]; int compNum = Integer.parseInt(quantity.getText()); double totalPrice = price * compNum; String outputS = " $ " + totalPrice; outputArea.setText( outputS ); } else if (yearIndex == 1) { double price = payList1[compIndex]; int compNum = Integer.parseInt(quantity.getText()); double totalPrice = price * compNum; String outputS = " $ " + totalPrice; outputArea.setText( outputS ); } else if (yearIndex == 2) { double price = payList2[compIndex]; int compNum = Integer.parseInt(quantity.getText()); double totalPrice = price * compNum; String outputS = " $ " + totalPrice; outputArea.setText( outputS ); } else if (yearIndex == 3) { double price = payList3[compIndex]; int compNum = Integer.parseInt(quantity.getText()); double totalPrice = price * compNum; String outputS = " $ " + totalPrice; outputArea.setText( outputS ); } else if (yearIndex == 4) { double price = payList4[compIndex]; int compNum = Integer.parseInt(quantity.getText()); double totalPrice = price * compNum; String outputS = " $ " + totalPrice; outputArea.setText( outputS ); } else if (yearIndex == 5) { double price = payList5[compIndex]; int compNum = Integer.parseInt(quantity.getText()); double totalPrice = price * compNum; String outputS = " $ " + totalPrice; outputArea.setText( outputS ); } else if (yearIndex == 6) { double price = payList6[compIndex]; int compNum = Integer.parseInt(quantity.getText()); double totalPrice = price * compNum; String outputS = " $ " + totalPrice; outputArea.setText( outputS ); } else if (yearIndex == 7) { double price = payList7[compIndex]; int compNum = Integer.parseInt(quantity.getText()); double totalPrice = price * compNum; String outputS = " $ " + totalPrice; outputArea.setText( outputS ); } else if (yearIndex == 8) { double price = payList8[compIndex]; int compNum = Integer.parseInt(quantity.getText()); double totalPrice = price * compNum; String outputS = " $ " + totalPrice; outputArea.setText( outputS ); } else if (yearIndex == 9) { double price = payList9[compIndex]; int compNum = Integer.parseInt(quantity.getText()); double totalPrice = price * compNum; String outputS = " $ " + totalPrice; outputArea.setText( outputS ); } else if (yearIndex == 10) { double price = payList10[compIndex]; int compNum = Integer.parseInt(quantity.getText()); double totalPrice = price * compNum; String outputS = " $ " + totalPrice; outputArea.setText( outputS ); } } }