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: a implementation of bq algorithm arithmetic coding for data compression, perform better seminar long beach, arithmetic operations using applet, java awt projects with source code, linux bash multiplication arithmetic expression expecting primary, java program to design student registration form using awt, source code of registration form using awt,

[-]
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,726 20-04-2013, 11:59 AM
Last Post: T
  Program in “LEX” to count number of vowels and consonants seminar class 2 9,691 22-03-2013, 10:20 AM
Last Post: computer topic
  Program in “LEX” to count number of Identifiers and Keywords seminar class 1 4,923 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,455 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,385 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,316 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,692 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,444 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,566 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,811 10-08-2011, 11:42 AM
Last Post: smart paper boy

Forum Jump: