0% found this document useful (0 votes)
459 views4 pages

Applet Program in Java For Add, Sub, Mul, Div...... !

Applet program with three text box and four button add,sub,mul,div and also have radio button and list?

Uploaded by

kantgaurav
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
459 views4 pages

Applet Program in Java For Add, Sub, Mul, Div...... !

Applet program with three text box and four button add,sub,mul,div and also have radio button and list?

Uploaded by

kantgaurav
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Applet program in java for add ,sub, div, mul which take 2 input in the textbox 1st and

2nd and give the give the result according to the pressed button and also have the checkbox group(radio button ) And list ?

Program:import import import import import import java.io.*; java.awt.*; java.awt.event.*; java.lang.*; java.util.*; java.applet.*;

public class appls extends Applet implements ActionListener,ItemListener { Label l1; Label l2; Choice ch; TextField t1; TextField t2; TextField t3; Button b1; Button b2; Button b3; Button b4; CheckboxGroup cg1; Checkbox c1; Checkbox c2; Checkbox c3; Checkbox c4; public void init() { setBackground(Color.pink); b1=new Button(" Add "); b2=new Button(" Sub "); b3=new Button(" Mul "); b4=new Button(" Div "); ch=new Choice(); l1=new Label("Enter The First No"); l2=new Label("Enter The Second No"); t1=new TextField(10); t2=new TextField(10); t3=new TextField(10); cg1=new CheckboxGroup(); c1=new c2=new c3=new c4=new add(l1); add(t1); Checkbox("India",cg1,false); Checkbox("USA",cg1,false); Checkbox("Sri Lanka",cg1,false); Checkbox("Bangladesh",cg1,false);

add(l2); add(t2); add(t3); add(b1); add(b2); add(b3); add(b4); add(c1); add(c2); add(c3); add(c4); ch.add("Java"); ch.add("C++"); ch.add("C"); ch.add("OS"); add(ch); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); b4.addActionListener(this); c1.addItemListener(this); c2.addItemListener(this); ch.addItemListener(this); c3.addItemListener(this); c4.addItemListener(this); } public void actionPerformed(ActionEvent ae) { String s1=t1.getText(); String s2=t2.getText(); String s3=ae.getActionCommand(); if(s3.equals(" { Add "))

int x=Integer.parseInt(s1); int y=Integer.parseInt(s2); int res=0; res=x+y; String s8=Integer.toString(res); t3.setText(s8); t1.setText(""); t2.setText(""); } if(s3.equals(" { Sub "))

int x=Integer.parseInt(s1); int y=Integer.parseInt(s2); int res=0; res=x-y; String s4=Integer.toString(res); t3.setText(s4); t1.setText(""); t2.setText(""); }

if(s3.equals(" {

Mul

"))

int x=Integer.parseInt(s1); int y=Integer.parseInt(s2); int res=0; res=x*y; String s5=Integer.toString(res); t3.setText(s5); t1.setText(""); t2.setText(""); } if(s3.equals(" { Div "))

int x=Integer.parseInt(s1); int y=Integer.parseInt(s2); int res=0; res=x/y; String s6=Integer.toString(res); t3.setText(s6); t1.setText(""); t2.setText(""); } } public void itemStateChanged(ItemEvent ie) { if(ie.getSource()==c1) { if(c1.getState()==true) { showStatus("Welcome to India"); } } if(ie.getSource()==c2) { if(c2.getState()==true) { showStatus("Welcome to USA"); } } if(ie.getSource()==c3) { if(c3.getState()==true) { showStatus("Welcome to Sri lanka"); } } if(ie.getSource()==c4) { if(c4.getState()==true) { showStatus("Welcome to Bangladesh"); }

} if(ie.getSource()==ch) { showStatus(ch.getSelectedItem()); } } } /*<applet code=appls height=200 width=200> </applet>*/

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy