Professional Documents
Culture Documents
Output:
C:\jdk1.8\bin>javac Largestinset.java
C:\jdk1.8\bin>java Largestinset
Largest of these are=19
Output:
C:\jdk1.8\bin>javac Factorial.java
C:\jdk1.8\bin>java Factorial
Factorial is=6
Output:
C:\jdk1.8\bin>javac BinTri.java
C:\jdk1.8\bin>java BinTri
1
01
010
1010
10101
Output:
C:\jdk1.8\bin>javac Largest.java
C:\jdk1.8\bin>java Largest
Largest of the three numbers is=150
Output:
C:\jdk1.8\bin>javac CityGuide.java
C:\jdk1.8\bin>java CityGuide
Select your choice
M----> Madras
B----> Bombay
C----> Calcutta
choice---->M
Madras:Booklet5
5
Output:
C:\jdk1.8\bin>javac evenodd.java
C:\jdk1.8\bin>java evenodd
2 is even
5 is odd
7 is odd
8 is even
15 is odd
even numbers are:2 odd numbers:3
Output:
C:\jdk1.8\bin>javac Largestof3.java
C:\jdk1.8\bin>java Largest
Largest of the three number is=200
Output:
C:\jdk1.8\bin>javac sorting.java
C:\jdk1.8\bin>java sorting
After iteration1, the values are
3 10 14 17 21 30 37 8 12
After iteration2, the values are
3 8 14 17 21 30 37 10 12
After iteration3, the values are
3 8 10 17 21 30 37 14 12
After iteration4, the values are
3 8 10 12 21 30 37 17 14
After iteration5, the values are
3 8 10 12 14 30 37 21 17
After iteration6, the values are
3 8 10 12 14 17 37 30 21
After iteration7, the values are
3 8 10 12 14 17 21 37 30
After iteration8, the values are
3 8 10 12 14 17 21 30 37
After iteration9, the values are
3 8 10 12 14 17 21 30 37
Sorted numbers are:
3 8 10 12 14 17 21 30 37
Output:
javac Face.java
appletviewer Face.java
10
Output:
javac Face.java
appletviewer Face.java
11
Output:
javac Face.java
appletviewer Face.java
12
12. To Take Input Value in Text Field and to Show the Results in
VIEWER.
APPLET
import java.awt.*;
import java.applet.*;
public class UserIn extends Applet
{
TextField text1, text2;
public void init()
{
text1 = new TextField(8);
text2 = new TextField(8);
add (text1);
add (text2);
text1.setText ("0");
text2.setText ("0");
}
public void paint(Graphics g)
{
int x=0, y=0, z=0;
String s1,s2,s;
g.drawString("Input a number in each box ", 10, 50);
try
{
s1 = text1.getText();
x = Integer.parseInt(s1);
s2 = text2.getText();
y = Integer.parseInt(s2);
}
catch (Exception ex) {}
z = x + y;
s = String.valueOf(z);
g.drawString("THE SUM IS: ", 10, 75);
g.drawString(s,100,75);
}
public boolean action(Event event, Object obj)
{
repaint();
return true;
}
}
<APPLET
CODE = UserIn.class
13
WIDTH = 250
HEIGHT = 200>
</APPLET>
Output:
javac UserIn.java
appletviewer UserIn.html
14