Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
Ex. No : 1
Date: 22-07-2021 Find area, perimeter of circle
Aim
To find area and perimeter of a circle by using buffered reader class.
ALGORITHM
Step1: Start the process
Step2: Get the input for radius from the user
Step3: Assign area= 3.14 x radius x radius
Step4: Assign perimeter= 2 x 3.14 x radius
Step6: Display area, perimeter
Step7: Stop the process
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
START
INPUT RADIUS
AREA=3.14X RADIUS X RADIUS
PERIMETER=2 X3.14X RADIUS
DISPLAYAREA
PERIMETER
STOP
RESULT:
Thus the output has been verified for area and perimeter of a circle using
buffered reader class.
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
Ex. No: 2
Date : Substring removal from String
AIM
To write a program for remove a substring from a String using
String Buffer Class.
ALGORITHM
Step1: Start the process
Step2: Get a string from a user
Step3: Find the index of the substring
Step4: Get the substring from the user
Step5: Find the index of the substring
Step6: Delete the substring from the string
Step7: Display the Substring from the string
step8: Stop the process
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
START
INPUT STRING1
[Link] ()
INPUT STRING2
START-INDEX=[Link] OF (STRING1)
DELETE ( [Link], [Link] )
+START-INDEX
PRINT STRING
STOP
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
RESULT:
Thus the output has been verified for remove a substring from a String
using String Buffer Class.
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
Ex. No: 3
Date :
Random Number Generation
AIM
To write a program for Determining the order of numbers
generated randomly using Random Class
ALGORITHM
Step1: Start the process
Step2: Create a random class
Step3: Find the random number generated between 0 to 100
Step4: Point the random number
Step5: Arrange the random number in ascending order
Step6: Print the number
Step7: Stop the process
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
START
Random r=new Random()
for(I=0;I<10;I++)
print a[i]
NEXT I
FOR(I=0;I<10;I++)
for(I=0;I<10;I++)
for(J=0;J<10;J++)
Yes No
IF(A[I]>=A[J]
S=A[I]
A(I)=A(I+1)
A(I+1)=S
NEXT I,J
FOR(I=0;I<10;I++)
PRTINTa[i]
NEXT I
STOP
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
RESULT:
Thus the output has been verified for Determining the order of numbers
generated randomly using Random Class
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
Ex. No: 4
Date :
Implementation of Point Class
AIM
To write a program for Implementing of Point Class.
ALGORITHM
Step1: Start the process
Step2: Declare and get X, Y Coordinates
Step3: Get Row, Column Displacement points p1, p2 using Point class
Step4: If p1.X and p2.X are equal and p1.Y and p2.Y are equal print it is
Invalid Coordinates
Step5: If p1.X and p2.X are equal print it is Vertical Line
Step6: If p1.Y and p2.Y are equal print it is Horizontal Line
Step7: If p1.X and p1.Y are equal print it is Square else print Rectangle
Step8: Call the method [Link](X, Y) and p2. Translate(X, Y)
Step9: Stop the process
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
START
Declare x,y,x1,y1,s
Input x,y,x1,y1 using
BufferredReader class
YES If([Link]()==[Link]()&
&[Link]()=[Link]())
Print
Invalid Coordinate NO
YES If([Link]()==[Link]())
Print vertical
line
NO
YES if([Link]()==[Link]())
Print
horizontal NO
line
if([Link]()==[Link]())
NO
YES
Print square Print rectangle
Print The translated coordinate:
[Link](),[Link](),[Link](),[Link]()
STOP
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
RESULT
Thus the different image manipulations are done successfully using
Point Class.
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
Ex. No: 5
Date : Usage of Calendar class
AIM
To write a program for finding current year is leap or not, using
Calendar class.
ALGORITHM
Step1: Start the process
Step2: Declare an array of month as string
Step3: Print current date and time using calendar class
Step4: Check whether the current year is leap year or not and print it
Step5: Stop the process.
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
START
STRING MATH[]={INT
YEARS}
GREGORIANCALENDAR GCALENDAR=NEW
GREGORIANCALENDAR
PRINT
(“DATE”+[Link]
)
[Link]
[Link]
IF YES
NO
GCALENDAR .ISLEA
PYEAR(YEAR)
PRINT NOT LEAP PRINT LEAP YEAR
YEAR
STOP
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
RESULT
Thus the given date of year is checked whether it is Leap or not,
using Calendar Class.
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
[Link]: 6
Date : String manipulation using char Array
AIM
To write a program for manipulating String by finding given String
is Palindrome or not, using Char Array.
Algorithm:
Step1: Start the process
Step2: Get the string from the user
Step3: Find the length of the string
Step4: Display the string
Step5: Reverse the string using char array
Step6: Display the reverse string
Step7: Check the condition for palindrome
Step8: print the result
Step9: stop the process.
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
START
INPUT
STRINGH
L=[Link]
FOR(I=L-1,J=0;J>=0;I--,J++)
R[J]=C[J]
PRTINTR[J]
NEXT I
FOR(I<0;I<=L-1;I++)
Yes NO
F=1 IF F=0
R[J]=C[J]
BREAK
NEXT I
PRINT PRINT “NOT A
IF F=1
“PALINDROME PALINDROME”
”
STOP
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
RESULT:
Thus the output has been verified for manipulating String by finding
given String is Palindrome or not, using Char Array
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
[Link]: 7
Date Working with Panel and Layout
A IM
To write a program creating for panel and placing it in different
layout along with different components.
ALGORITHM
Step1: start the process
Step2: create panel
Step3: get layouts
Step4: create button and add button inside panels
Step5: stop the process
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
START
PANEL P1, P2,P3,P4,P5
[Link] layout(flow layout())
[Link](Grid Layout())
[Link](Border Layout())
STOP
RESULT
The panel and its different layout along with different components
are worked successfully using AWT controls.
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
[Link]: 8
Date : Usage of Vector class
AIM
To write a program for implement usage of vector class.
Algorithm:
Step1: start the process
Step2: create a vector class
Step3: add the elements in vector
Step4: display the size and capacity of the vector
Step5: display all the elements in vector
Step6: stop the process.
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
START
VECTOR=NEW VECTOR ()
[Link] ELEMENT INTEGER (5)
[Link] ELEMENT (NEW INTEGER (5.5))
PRINT [Link] ()
ENUMERATION = [Link] ()
WHILE
No
E . HAS MORE
ELEMENTS ()
Yes
PRINT
E.NEXT3ELEMENT
STOP
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
RESULT:
Thus the output has been verified for implement usage of vector class
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
[Link]: 9 Implementing Thread based application &
Date : Exception Handling
AIM
To write a program for implement Thread based Applications and
Exception Handling.
ALGORITHM
Step1: start the process
Step2: declare thread learning
Step3: implement the thread T.
Step4: to make thread sleep
Step5: stop the process
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
START
STRINGNAME
STRING LIST[]={}
[Link]
[Link]
FOR(INT I=0;I<[Link]();I++)
PRINT(NAME+LIST(1))
[Link]()
[Link]()
NEXT I
STOP
RESULT
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
Thus the output has been verified for Thread based application &
Exception handling.
Ex. No: 10
Date : Working with Menus
A IM
To create a menu item in the applet window.
ALGORITHM
Step1: start the process
Step2: create menu bar, menu, menu item and text area.
Step3: on selection of menu item in the applet window
Step4: stop the process.
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
START
Class menu extends Applet
implements ActionListener
Init()
ActionPerformed()
Class menucreation()extends
Frame
Menucreation()
STOP
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
RESULT
The Menu items are worked successfully using Applet.
awt controls.
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
Ex. No: 11
Date : Incorporating Graphics
A IM
To write a program creating various shapes using graphical
statements.
ALGORITHM
Step1: start the process
Step2: create oval, rectangle, square and circle using their graphical statements
Step3: specify x and y co-ordinates
Step4: draw polygon using graphical statement
Step5: stop the process
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
START
class graph extends Applet
void init()
void paint(Graphics g)
[Link](100,20,50,50);
[Link](200,20,80,50,50,60);
[Link](20,100,50,80);
[Link](100,130,50,50);
[Link](x,y,n);
[Link](a,b,n);
STOP
RESULT:
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
Thus the output has been verified for drawing various shapes using
graphical statements in the applet.
Ex. No. 12
Date : Working with Font and Color
AIM
To display various fonts and its style in different colors.
ALGORITHM
Step1: start the process
Step2: Set the colors to the text
Step3: set the font type and set the font size
Step4: display text and its style
Step5: stop the process
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
Flowchart for fonts and colors:
START
Class font extends Applet
Font f;
String s;
Void paint()
setBackground([Link]);
[Link]([Link]);
f=new Font("Arial",[Link],25);
[Link](f);
[Link]("VELSUNIVERSITY-VISTAS",10,50);
STOP
Programming in Java Record Page:
Department of Computer Science Vels Institute of Science, Technology &
Advanced Studies
RESULT
Thus the output has been verified for various colors and fonts
using AWT controls.
Programming in Java Record Page: