Guys please help me on my program, this is a GUI java program, and I'm having problem every time I run it. It doesn't give me any output on every given I enter, it got an error always. This is a Confidence Interval of know variance, that's the title of my program.. I want it to give me an output every time I press the calculate button. Here's the code..
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MyProgram2 extends JFrame implements ActionListener{ JLabel heading = new JLabel("Given:"); JLabel sSize = new JLabel("Sample Size"); JLabel sMean = new JLabel("Sample Mean"); JLabel var = new JLabel("Variance"); JLabel ConfInt = new JLabel("Confidence Interval"); JLabel ans = new JLabel("Two sided"); JTextField textA = new JTextField(7); JTextField textB = new JTextField(7); JTextField textC = new JTextField(7); JTextField textD = new JTextField(7); JTextField textE = new JTextField(7); JTextField textF = new JTextField(7); JTextField ConfInttext = new JTextField(7); JTextField resultA = new JTextField(7); JTextField resultB = new JTextField(7); JButton calculate = new JButton("Calculate"); JPanel hedpanel = new JPanel(); JPanel row1 = new JPanel(); JPanel row2 = new JPanel(); JPanel row3 = new JPanel(); JPanel row4 = new JPanel(); JPanel result = new JPanel(); JPanel butpanel = new JPanel(); double a; double b; double c; double d; double e; double f; double g; double finalans; double h; double i; double j; double k; double l; double m; double n; double finalans2; public MyProgram2(){ setTitle("Confidence Interval of two Population Mean"); resultA.setEditable(false); resultB.setEditable(false); setLayout(new FlowLayout()); //Add component to Panel hedpanel.add(heading); row1.add(sSize); row1.add(textA); row1.add(textB); row2.add(sMean); row2.add(textC); row2.add(textD); row3.add(var); row3.add(textE); row3.add(textF); row4.add(ConfInt); row4.add(ConfInttext); result.add(ans); result.add(resultA); result.add(resultB); butpanel.add(calculate); //Frame add(hedpanel); add(row1); add(row2); add(row3); add(row4); add(result); add(calculate); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); calculate.addActionListener(this); } //the Application public void calcCIL(){ finalans = (c-d)-g*Math.sqrt((Math.pow(e,2)/a)+(Math.pow(f,2)/b)); } public void calcCIR(){ finalans2 = (j-k)+n*Math.sqrt((Math.pow(l,2)/h)+(Math.pow(m,2)/i)); } public void actionPerformed(ActionEvent evt){ String userIn; userIn = textA.getText(); a = Integer.parseInt(userIn); h = Integer.parseInt(userIn); userIn = textB.getText(); b = Integer.parseInt(userIn); i = Integer.parseInt(userIn); userIn = textC.getText(); c = Integer.parseInt(userIn); j = Integer.parseInt(userIn); userIn = textD.getText(); d = Integer.parseInt(userIn); k = Integer.parseInt(userIn); userIn = textE.getText(); e = Integer.parseInt(userIn); l = Integer.parseInt(userIn); userIn = textF.getText(); f = Integer.parseInt(userIn); m = Integer.parseInt(userIn); userIn = ConfInt.getText(); g = Integer.parseInt(userIn); n = Integer.parseInt(userIn); resultA.setText(finalans+""); repaint(); calcCIL(); resultB.setText(finalans2+""); repaint(); calcCIR(); } public static void main(String[] args){ MyProgram2 prog = new MyProgram2(); prog.setSize(350, 290); prog.setResizable(false); prog.setVisible(true); } }