-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinputinapp.java
36 lines (29 loc) · 881 Bytes
/
inputinapp.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.awt.*;
import java.applet.*;
public class inputinapp extends Applet
{
TextField t1, t2;
public void init()
{
t1 = new TextField(10);
t2 = new TextField(10);
add(t1);
add(t2);
t1.setText("0");
t2.setText("0");
}
public void paint(Graphics g)
{
int a=0,b=0,c=0;
String str1,str2,str;
g.drawString("Enter the number in each box",10,50);
str1=t1.getText();
a=Integer.parseInt(str1);
str2=t2.getText();
b=Integer.parseInt(str2);
c=a+b;
str=String.valueOf(c);
g.drawString("Sum is",10,15);
g.drawString(str,100,75);
}
}