S Lab Record
S Lab Record
Name :
Register Number :
Subject Name :
Subject Code :
Batch :
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Date: Internal:
External:
Vision of Institution
To build Jeppiaar Engineering College as an Institution of Academic Excellence in Technical
education and Management education and to become a World Class University.
Mission of Institution
M1 To excel in teaching and learning, research and innovation by promoting the principles of
scientific analysis and creative thinking
PEO3 Work in a business environment, exhibiting team skills, work ethics, adaptability and lifelong
learning.
PSO1 Exhibit design and programming skills to build and automate business solutions using cutting edge
technologies.
PSO2 Strong theoretical foundation leading to excellence and excitement towards research, to provide
elegant solutions to complex problems.
PSO3 Ability to work effectively with various engineering fields as a team to design, build and develop
system applications
COURSE OUTCOMES:
CO1 Design and develop java programs using object oriented programming concepts
CO2 Develop simple applications using object oriented concepts such as package, exceptions
06 Illustration of multi-threading
AIM:
To develop a Java application to Sequential search, Binary search and quadratic sorting algorithms.
ALGORITHM:
Step 1: Start
Step 2.1: First, we have to traverse the array elements using a for loop.
Step 2.2: In each iteration of for loop, compare the search element with the current array element,
Step 2.2.1: If the element matches, then return the index of the corresponding array element
Step 2.2.2: If the element does not match, then move to the next element. Step 2.2.3: If there
is no match or the search element is not present in the given array, return -1
Step 4.3: Replace the value at location Min with a different value. Step 4.4: Increase Min to point
to the next element
Step 5.2: Compare the current element (key) to one that came before it.
Step 5.3: If the data at the current index is less than the data at the previous index, you will
compare it to the element before it
Step 5.4: You will shift bigger elements to the next index to make space for swapped elements, and
then you will iterate the same steps again to sort the complete array.
Step 7: Stop
PROGRAM:
Sequential Search:
class Sequential_Search {
// Function for linear search
public static int search(int arr[], int x)
{
int n = arr.length;
// Traverse array arr[]
for (int i = 0; i < n; i++) {
// Element to search
int x = 10;
// Function Call
int result = search(arr, x);
if (result == -1)
System.out.print(
"Element is not present in array");
else
System.out.print("Element is present" + " at index " + result);
}
}
Binary Search:
class BinarySearch {
// Function that returns index of
// x if it is present in arr[l, r]
int binarySearch(int arr[], int l, int r, int x)
{
if (r >= l) {
int mid = l + (r - l) / 2;
// If the element is present
// at the middle itself
if (arr[mid] == x)
return mid;
// If element is smaller than
// mid, then it can only be
// present in left subarray
if (arr[mid] > x)
Selection Sort:
class SelectionSort
{
void sort(int arr[])
{
int n = arr.length;
// One by one move boundary of unsorted subarray
for (int i = 0; i < n-1; i++)
{
// Find the minimum element in unsorted array
int min_idx = i;
for (int j = i+1; j < n; j++)
if (arr[j] < arr[min_idx])
min_idx = j;
Insertion Sort
OUTPUT:
Sequential Search
Element is present at index 4
Binary Search
Element is present at index 4
Selection Sort
Sorted Array 11 12 22 25 64
Insertion Sort
5 6 11 12 13
RESULT
AIM:
To develop a stack and queue data structures using classes and objects.
ALGORITHM:
Step 1: push inserts an item at the top of the stack (i.e., above its current top element).
Step 2: pop removes the object at the top of the stack and returns that object from the function.
The stack size will be decremented by one.
Step 3: isEmpty tests if the stack is empty or not.
Step 4: isFull tests if the stack is full or not.
Step 5: peek returns the object at the top of the stack without removing it from the stack or
modifying the stack in any way.
Step 6: size returns the total number of elements present in the stack.
PROGRAM:
Stack Implementation
class Stack
{
private int arr[];
private int top;
private int capacity;
// Constructor to initialize the stack
Stack(int size)
{
arr = new int[size];
capacity = size;
top = -1;
}
// Utility function to add an element `x` to the stack
public void push(int x)
{
if (isFull())
{
System.out.println("Overflow\nProgram Terminated\n");
OUTPUT
Inserting 1
Inserting 2
Removing 2
Removing 1
Inserting 3
Removing 3
Queue Implementation
import java.util.LinkedList;
import java.util.Queue;
class Main
{
public static void main(String[] args)
OUTPUT
The front element is A
The front element is C
The queue size is 2
The queue is not empty
RESULT
AIM
To develop a java application to generate pay slip for different category of employees using the
concept of inheritance.
EXPLANATION
Develop a java application with Employee class with Emp_name, Emp_id, Address, Mail_id,
Mobile_no as members. Inherit the classes, Programmer, Assistant Professor, Associate Professor
and Professor from employee class. Add Basic Pay (BP) as the member of all the inherited classes
with 97% of BP as DA, 10 % of BP as HRA, 12% of BP as PF, 0.1% of BP for staff club fund.
Generate pay slips for the employees with their gross and net salary
ALGORITHM
PROGRAM
package employee;
import java.io.IOException;
import java.util.Scanner;
class Emp
{
String ename,Address,email;
int eid;
int mobile;
void getEmployeedetails()
{
Scanner in = new Scanner(System.in);
System.out.println("Enter the Emp_id. :");
eid=in.nextInt();
System.out.println("Enter the Employee Name:");
ename=in.next();
System.out.println("Enter the Employee Address:");
Address=in.next();
System.out.println("Enter the Employee Email id :");
email=in.next();
}
public class Employee
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.println("Choose the type Employee");
System.out.println("1.Programmer ,2.Assistant Professor,3.Associate Professor ,4.Professor: ");
int ch=in.nextInt();
switch(ch)
{
case 1: System.out.println("PROGRAMMER DETAILS");
Programmer p=new Programmer();
p.Programmerdetails();
break;
case 2: System.out.println("Assistant Professor DETAILS");
AssistantProfessor ap=new AssistantProfessor();
ap.APDetails();
OUTPUT
RESULT
AIM
To write a java program to calculate the area of rectangle,circle and triangle using the concept of
abstract class.
EXPLANATION
Write a Java Program to create an abstract class named Shape that contains two integers and
an empty method named print Area(). Provide three classes named Rectangle, Triangle and Circle
such that each one of the classes extends the class Shape. Each one of the classes contains only the
method print Area () that prints the area of the given shape.
ALGORITHM
STEP 1: Create an abstract class with the name shape
STEP 1.1: Let sides of shape be Side1 and Side2, create variables Side1, Side2
STEP 1.2: Define an empty method PrintArea()
STEP 2: Create three classes with names Rectangle, Triangle and Circle
STEP 2.1: Extend the Shape class in each of these classes
STEP 2.2: Develop the implementation of Area in each class appropriately
STEP 2.3: For Eg: PrintArea() of Circle would be 3.14*Side1*Side1 ; here Side1 is considered as
circle’s radius
STEP 3: Write a class with main method
STEP 4: Create instance of all three classes
STEP 5: Calculate the Area for each shape
STEP 6: Display the area
PROGRAM
RESULT
AIM
ALGORITHM
PROGRAM
package example1;
class MyException extends Exception{
String str1;
MyException(String str2) {
str1=str2;
}
public String toString(){
return ("MyException Occurred: "+str1);
}
}
public class Example1 {
public static void main(String[] args)
{
try{
System.out.println("Starting of try block");
// I'm throwing the custom exception using throw
throw new MyException("This is My error Message");
}
catch(MyException exp){
System.out.println("Catch Block");
System.out.println(exp);
}
}
}
RESULT
AIM
EXPLANATION
Write a java program that implements a multi-threaded application that has three threads.
First thread generates a random integer every 1 second and if the value is even, second thread
computes the square of the number and prints. If the value is odd, the third thread will print the value
of cube of the number.
ALGORITHM
PROGRAM
package mtherad;
import java.util.*;
class even implements Runnable{
public int x;
public even(int x){
this.x=x;
}
@Override
public void run()
{
System.out.println("Thread Name:Even Thread and square is: " + x * x);
}
}
OUTPUT:
RESULT
AIM
To write a java program that reads a file name from the user, displays information about
whether the file exists, whether the file is readable, or writable, the type of file and the length of the
file in bytes.
EXPLANATION
Write a Java program that reads a file name from the user, displays information about
whether the file exists, whether the file is readable, or writable, the type of file and the length of the
file in bytes.
ALGORITHM
STEP 1: Create a text file with some contents
STEP 1.1: Let the name of file be ‘Example.txt’
STEP 1.2: Enter some content and save in the same folder as java program
STEP 2: Create a class with main method
STEP 2.1: Create a file object
STEP 2.2: Print all the attributes of the file objects
PROGRAM
package Filedemo;
import java.util.Scanner;
import java.io.File;
public class Filedemo {
public static void main(String[] args)
{
String filename;
Scanner s=new Scanner(System.in);
System.out.println("Enter the file name ");
filename=s.nextLine();
File f1=new File(filename);
System.out.println("*****************");
System.out.println("FILE INFORMATION");
System.out.println("*****************");
System.out.println("NAME OF THE FILE "+f1.getName());
System.out.println("PATH OF THE FILE "+f1.getPath());
System.out.println("PARENT"+f1.getParent());
}
}
OUTPUT
RESULT
AIM
ALGORITHM
PROGRAM
OUTPUT
JEC
3108
RESULT
Date:
AIM
ALGORITHM
PROGRAM
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.*;
import javafx.stage.Stage;
public class Label_Test extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
BorderPane BPane = new BorderPane();
BPane.setTop(new Label("This will be at the top"));
BPane.setLeft(new Label("This will be at the left"));
BPane.setRight(new Label("This will be at the Right"));
BPane.setCenter(new Label("This will be at the Centre"));
OUTPUT
Menu
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class MenuExample extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
// TODO Auto-generated method stub
BorderPane root = new BorderPane();
}
}
OUTPUT
RESULT
AIM
To develop a mini project for Ping Pong game application using JavaFX controls, layouts.
ALGORITHM
OUTPUT