Summing Two Integers & Floats at the Keyboard.
/* Example1.java

< applet
code=Example1
width=225
height=300 >
< /applet >


This example will demonstrate how to enter two integers
and two floats at the keyboard.  It will then sum the 
two sets of numbers, and output the result using the
appendText method.*/

import java.applet.*; //imports Applet package
import java.awt.*; //imports the abstract window Tool Kit (AWT) class.

public class Example1 extends Applet
{
  TextField StrNum1=new TextField(10);
  TextField StrNum2=new TextField(10);
  TextField StrNum3=new TextField(10);
  TextField StrNum4=new TextField(10);
  Button FindSum=new Button ("Find Sums");
  Label Prompt1=new Label ("Enter an Integer :");
  Label Prompt2=new Label ("Enter another Integer :");
  Label Prompt3=new Label ("Enter a float :");
  Label Prompt4=new Label ("Enter another float :");
  TextArea Result=new TextArea(5,30);


public void init()
{
       
    add(Prompt1);
    add(StrNum1);
    
    add(Prompt2);
    add(StrNum2);
    
    add(Prompt3);
    add(StrNum3);
    
    add(Prompt4);
    add(StrNum4);
    
	
    add(FindSum);
    add(Result);
}

public boolean action(Event thisEvent, Object thisObject)
{
    /*The next line will get the input from the 
    textfield and convert it to an integer*/
    int num1=Integer.parseInt(StrNum1.getText());
    int num2=Integer.parseInt(StrNum2.getText());//entering the second integer
   

    /*The next line will get the input from the                                                                                             
    textfield and convert it to a float*/
    float num3=Float.valueOf(StrNum3.getText()).floatValue();
    float num4=Float.valueOf(StrNum4.getText()).floatValue();
	
    int sumi= num1 + num2; // adding the integers
    float sumf = num3 + num4; // adding the floats
	
    Result.appendText("The sum of your integers :  "+num1+" and "+num2+"\n is "+sumi+"\n\n");
    Result.appendText("The sum of your floats :  "+num3+" and "+num4+"\n is "+sumf+"");
    return true;
}

}

Sample Output for Example1.java