PROGRAM TO PERFORM ARITHMETIC OPERATIONS USING AWT CONTROLS
#1

Code:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Choice.*;
//<applet code=Awte width=500 height=555></applet>
public class Awte extends Applet implements TextListener,ActionListener
{
int a,b,c;
String s;
TextField f1,f2,f3;
Label l1,l2,l3;
Button Add,Sub,Mul,Div;
public void init()
    {
        //setBackground(Color.green);
    setForeground(Color.red);
    l1=new Label("First number");
    l2=new Label("Second number");
                   l3=new Label("Result");
    f1=new TextField(10);
    f2=new TextField(20);
    f3=new TextField(20);
    //f3=new TextField(20);
    //f2.setEchochar("*");
    add(l1);
                     add(f1);
    add(l2);
    add(f2);
                   add(l3);
    add(f3);
        Add=new Button("Add");
    Sub=new Button("Sub");
                  Mul=new Button("Mult");
                 Div=new Button("Div");
    add(Add);
    add(Sub);
                    add(Mul);
                     add(Div);
        f1.addTextListener(this);
    f2.addTextListener(this);
    f3.addTextListener(this);
    Add.addActionListener(this);
    Sub.addActionListener(this);
                  Mul.addActionListener(this);
                  Div.addActionListener(this);
}

public void actionPerformed(ActionEvent ae)
{
    a=Integer.parseInt(f1.getText());
    b=Integer.parseInt(f2.getText());
    if(ae.getActionCommand().equals("Add"))
    c=a+b;
    else if(ae.getActionCommand().equals("Sub"))
    c=a-b;
else if(ae.getActionCommand().equals("Mult"))
    c=a*b;
                 else
    c=a/b;
    s=String.valueOf(c);
    repaint();
}


public void textValueChanged(TextEvent te)
{

}

public void paint(Graphics g)
    {    
    f3.setText(s);
    //g.drawString(String.valueOf(c),355,355);
    }

}


OUTPUT
E:\msc3\jiss\java>javac awte.java

E:\msc3\jiss\java>ap
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: registration form program using awt component in java, linux bash multiplication arithmetic expression expecting primary, perform better seminar long beach, a implementation of bq algorithm arithmetic coding for data compression, computer arithmetic algorithms software significance speed performance, how to do a java progam using awt comntrols, ppt arithmetic operation seminar,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Messages In This Thread
PROGRAM TO PERFORM ARITHMETIC OPERATIONS USING AWT CONTROLS - by project topics - 06-04-2011, 01:24 PM

Possibly Related Threads...
Thread Author Replies Views Last Post
  VHDL program for Booth’s Multiplier smart paper boy 2 5,674 20-04-2013, 11:59 AM
Last Post: T
  Program in “LEX” to count number of vowels and consonants seminar class 2 9,642 22-03-2013, 10:20 AM
Last Post: computer topic
  Program in “LEX” to count number of Identifiers and Keywords seminar class 1 4,858 28-01-2013, 03:21 PM
Last Post: Guest
  To perform multiple sequence alignment between the given sequences using Clustalw2 to smart paper boy 0 1,406 10-08-2011, 02:44 PM
Last Post: smart paper boy
  To perform global alignment between the given sequences using EMBOSS tool. smart paper boy 0 1,359 10-08-2011, 02:43 PM
Last Post: smart paper boy
  To perform local alignment between the given sequences using EMBOSS tool. smart paper boy 0 1,293 10-08-2011, 02:41 PM
Last Post: smart paper boy
  PROGRAM TO RECOGNIZE A STRING WITH THREE COSECUTIVE 0’s smart paper boy 0 1,675 10-08-2011, 11:44 AM
Last Post: smart paper boy
  : PROGRAM TO IDENTIFY VOWELS AND CONSONANTS GIVEN AS INPUT smart paper boy 0 2,413 10-08-2011, 11:44 AM
Last Post: smart paper boy
  Program to Encrypt and decrypt a text data using RSA algorithm smart paper boy 0 2,537 10-08-2011, 11:43 AM
Last Post: smart paper boy
  Program the CRC 12 on a data set of characters smart paper boy 0 1,777 10-08-2011, 11:42 AM
Last Post: smart paper boy

Forum Jump: