Java
Java
LABORATORY MANUAL
A. OVERVIEW
Year / Semester : B.Tech – 2/2 Sem Academic Year: 2012-13
Laboratory Title: Object Oriented Programming Laboratory Code: 54609
Total Contact Hours: 36 Duration of SEE: 03 Hours
B. OBJECTIVES
1. To plan the Laboratory activities so as to complete the experiments on time.
2. To write & complete the records at the end of each experiment.
3. To prepare the laboratory manual.
C. DESCRIPTION
1. LEARNING OBJECTIVES:
To do the program in java, students should know the programming in C language
Should know the OOP concepts
2. LEARNING OUTCOMES:
To make the students learn an object oriented way of solving problems
To teach the student to write programs in java to solve the problems
3. PREREQUISITES:
1. They should know how to compile the java programs
2. They should know how to run the java programs
4. BASE COURSE:
Object Oriented Programming
5. INTRODUCTION
6. RESOURSES REQUIRED
Good configured PC's
JDK software
7. GENERAL INSTRUCTIONS:
Maintain Lab records
Maintain the observation for the programs and bring to the lab when the lab is
working
8. CONTENTS:
Expt Date Date
No. Planned Conducted
1 Write a Program To print the Fibonacci series up to given 17/12/12
7 Write a Program That allow user to draw the line, rectangle 07/01/13
and ovals 10/01/13
12 Write a Program That reads a file and displays the file on 21/01/13
the screen within line number before each line 24/01/13
10. REFERENCE:
1. Java How to Program, sixth Edition, H.M.Dietel and P.J.Dietel, Pearson Education/PHI
2. Programming with JAVA, M.P.Bhave and S.A.Patekar, pearson Education
3. Java Programming, D S Malik, cengage learning, Indian edition.
D. EXPERIMENTS
2. TITLE:
Write a Program To print the Fibonacci series up to given numbers
3. LEARNING OBJECTIVES:
They will learn how to write the Fibonacci series using java
4. AIM:
Write a java program to generate the Fibonacci series, given number of n values
6. THEORY / HYPOTHESIS
BY DEFINITION, THE FIRST TWO FIBONACCI NUMBERS ARE 0 AND 1, AND EACH
SUBSEQUENT NUMBER IS THE SUM OF THE PREVIOUS TWO.
class Febinocci
{
public static void main(String args[])throws IOException
{
int n,f3, i;
A a=new A(0,1);
System.out.println("Enter how many numbers you want in febinoci series");
BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
n=Integer.parseInt(stdin.readLine());
System.out.println("The febinocci series is as follows");
System.out.print("\t" + 0);
System.out.print("\t" + 1);
for(i=0;i<(n-2);i++)
{
a.Feb();
} //End of for loop
} //End of main
} //END OF CLASS FEBINOCCI
F_n=F_(n-1)+F_(n-2)
0 1 1 2 3 5 8 13.......
15. REMARKS
-
-
-
FACULTY SIGNATURE
2. TITLE:
Program to Find The Primary Numbers
3. LEARNING OBJECTIVES:
They can able to write the java program on primari numbers
4. AIM:
Write a java program to find the given primary numbers.
6. THEORY / HYPOTHESIS
A PRIME NUMBER (OR A PRIME) IS A NATURAL NUMBER THAT HAS EXACTLY TWO DISTINCT
NATURAL NUMBER DIVISORS: 1 AND ITSELF
import java.io.*;
class prime
{
public static void main(String s[]) throws IOException
{
int i,j,c,n;
BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Positive value :");
n=Integer.parseInt(stdin.readLine());
for (i=1;i<=n;i++)
{
10
2
3
5
7
15. REMARKS
FACULTY SIGNATURE
2. TITLE:
Program To generate the Quadratic equation
3. LEARNING OBJECTIVES:
students can able to write the java program on quadratic equation
4. AIM:
Write a java program to generate the quadratic equation.
import java.math.*;
class quadratic
{
public static void main(String s[]) throws IOException
{
int a,b,c,d;
double r1,r2;
BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter value of a:");
a=Integer.parseInt(stdin.readLine());
System.out.println("Enter value of b:");
b=Integer.parseInt(stdin.readLine());
System.out.println("Enter value of c:");
Page No.: 8/55
Opposite Bhaghiratha Colony, JPN Nagar, Boothpur Road, MAHABUBNAGAR– 509001, AP (INDIA)
Phone: 91-8542-276111 / 33 / 44 / 55 Fax: 276122, Web: www.jpnes.org Email: director@jpnes.org
Jaya Prakash Narayan Educational Society Group of Institutions
Faculty of Engineering / Faculty of Pharmacy
c=Integer.parseInt(stdin.readLine());
d=b*b-4*a*c;
if(d==0)
{
System.out.println("Roots are Equalent");
15. REMARKS
FACULTY SIGNATURE
2. TITLE:
Program to implement Mouse Listener (Mouse Events)
3. LEARNING OBJECTIVES:
They can able to write the java program on mouse listeners
4. AIM:
Write a java program to implement the APPLET PACKAGES, draw Mouse event handler programs.
import java.applet.*;
import java.awt.event.*;
/*<applet code="MouseDemo" width=300 height=300>
</applet>*/
public class MouseDemo extends Applet implements MouseListener,MouseMotionListener
}
public void mouseEntered(MouseEvent me)
{
mx=40;
my=80;
msg="Mouse Entered";
repaint();
}
public void mouseExited(MouseEvent me)
{
mx=40;
my=80;
15. REMARKS
FACULTY SIGNATURE
2. TITLE:
Program to find multiplication of two matrices
4. AIM:
Write a Program To find the product of matrices
15. REMARKS
FACULTY SIGNATURE
3. LEARNING OBJECTIVES:
student will learn the concept of string tokenizers
15. REMARKS
FACULTY SIGNATURE
2. TITLE:
Program to draw Lines, Rectangles, Rounded Rectangles, filled Polygons and Ovals
3. LEARNING OBJECTIVES:
They will learn the concept of applet
4. AIM:
Write a java program to implement the APPLET PACKAGES, draw Lines, Rectangles, Rounded
Rectangles, filled Polygons programs.
FACULTY SIGNATURE
2. TITLE:
program to implement the palindrome of a given string
3. LEARNING OBJECTIVES:
They can able to write the java program on palindrome of a given string
4. AIM:
write a java program that checks a given string is a palindrome or not
15. REMARKS
FACULTY SIGNATURE
2. TITLE:
3. LEARNING OBJECTIVES:
They can able to write the java program on sorting of names in ascending order
4. AIM:
Write a java program for sorting a given list of names in ascending order
FACULTY SIGNATURE
2. TITLE:
Program to make frequency count of words in a given text
3. LEARNING OBJECTIVES:
students can write the program on to counting the no of words in the given text.
4. AIM:
Write a java program to make frequency count of words in a given text
15. REMARKS
FACULTY SIGNATURE
2. TITLE:
Java program to display the information of a file
3. LEARNING OBJECTIVES:
students can able to write the program on display the information of file in java language
4. AIM:
Write a Program That reads on a file and display the information that whether the file exists or
not, to display the information about the file and find the type of file whether readable,
writable and the length of bytes
15. REMARKS
FACULTY SIGNATURE
3. LEARNING OBJECTIVES:
They can able to write the java program on read the file and display the file
4. AIM:
Write a Program That reads a file and displays the file on the screen within line number before
each line
15. REMARKS
FACULTY SIGNATURE
1. EXPERIMENT NO: Date Planned Date Conducted Marks
XIII 28/01/13
31/01/13
2. TITLE:
Program to print number of characters, words, lines in the file
3. LEARNING OBJECTIVES:
They can able to write the program on number of characters, words, lines in the file
4. AIM:
Write a Program That prints a number of characters ,words,lines in that file
}
catch(IOException ie)
{
return;
}
System.out.println(lines+" "+words+" "+chars);
}
}
15. REMARKS
FACULTY SIGNATURE
2. TITLE:
Program to implement stack ADT
3. LEARNING OBJECTIVES:
students can able to write the java program on stack ADT
4. AIM:
Write a Program That
implements a stack ADT
15. REMARKS
FACULTY SIGNATURE
2. TITLE:
Program to implement infix expression into postfix expression
3. LEARNING OBJECTIVES:
students can able to write the java program on conversion of infix expression into postfix
expression
4. AIM:
Write a JAVA program to implement infix expression into postfix expression
15. REMARKS
FACULTY SIGNATURE
2. TITLE:
Develop an applet that receives an integer in one text field, and computes as factorial
value and returns it in another text field,when the button named “Compute” is clicked
3. LEARNING OBJECTIVES:
students will learn applet concepts.
4. AIM:
Develop an applet that receives an integer in one text field, and computes as factorial
value and returns it in another text field,when the button named “Compute” is clicked
15. REMARKS
FACULTY SIGNATURE
2. TITLE:
Program to display simple message using applet
4. AIM:
Write an applet that displays a simple message
/*
<applet code="Cal" width=300 height=300>
</applet>
*/
FACULTY SIGNATURE
2. TITLE:
Write a java program that works as a simple calculator.Use a grid layout to arrange buttons for
the digits +,-,*,/,% operations.Adda text field to display the result
3. LEARNING OBJECTIVES:
students can write the java program on grids.
4. AIM:
Write a java program that works as a simple calculator.Use a grid layout to arrange buttons for
the digits +,-,*,/,% operations.Adda text field to display the result
15. REMARKS
FACULTY SIGNATURE
1. EXPERIMENT NO: Date Planned Date Conducted Marks
IIX 18/03/13
21/03/13
2. TITLE:
Program for handling mouse events
3. LEARNING OBJECTIVES:
students can write the program on mouse events.
4. AIM:
Write a java program for handling mouse events
15. REMARKS
FACULTY SIGNATURE
2. TITLE:
Write a java program that creates three threads.First thread displays”Good Morning”
every one second,the second thread displays “Hello” every two seconds and the third thread
displays “Welcome” every three seconds
3. LEARNING OBJECTIVES:
students will write the program on threads.
4. AIM:
Write a java program that creates three threads.First thread displays”Good Morning”
every one second,the second thread displays “Hello” every two seconds and the third thread
displays “Welcome” every three seconds
15. REMARKS
FACULTY SIGNATURE
2. TITLE:
Write a java program that correctly implements producer consumer problem using the concept
of inter thread communication
3. LEARNING OBJECTIVES:
students can write the program on thread
4. AIM:
Write a java program that correctly implements producer consumer problem using the concept
of inter thread communication
15. REMARKS
FACULTY SIGNATURE