Java Answerz NEED

truth4L

Member
Jan 16, 2009
2,463
10
0
emotional hell
:):)
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package excel;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
*
* @author rajitha
*/
public class addition extends JFrame {

JTextField txt1, txt2;
JLabel lbl1, lbl2;
JButton btn1;
JPanel panel;

public addition() {
super("Integer Addition");
panel = new JPanel(new GridLayout(3, 2));
txt1 = new JTextField();
txt2 = new JTextField();
lbl1 = new JLabel("Integer 1 :- ");
lbl2 = new JLabel("Integer 2 :- ");
btn1 = new JButton("Add");
panel.add(lbl1);
panel.add(txt1);
panel.add(lbl2);
panel.add(txt2);
panel.add(btn1);
add(panel);
setLocationRelativeTo(null);
setSize(200, 150);
addAction();
}

void addAction() {
btn1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
int no1 = Integer.parseInt(txt1.getText());
int no2 = Integer.parseInt(txt2.getText());
JOptionPane.showMessageDialog(null, "Result = " + (no1 + no2));
}
});
}

public static void main(String[] args) {
addition a=new addition();
a.setVisible(true);
a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
 

kpg

Well-known member
  • Jun 3, 2008
    3,445
    1,805
    113
    In My Home
    02)write a java program to find the surface of the sphere. Radius of the
    sphere may be any number that user gives.

    03)write a java program to print day of the week with respect to its number
    For the Illustration,if you give a number 4,it will print "Wednesday"
    In this Program,Switch-case statement is expected to use