0% found this document useful (0 votes)
14 views31 pages

Aman Tarafdar XI - B

This document is a practical file for Computer Science by Aman Tarafdar, a student of Delhi Public School Newtown, for the batch 2024-25. It includes a certificate of authenticity, a table of contents listing various programming topics and algorithms, and source code examples for each topic. The practical work covers object-based programming, arrays, data structures, inheritance, recursion, and miscellaneous programs.

Uploaded by

rehantarafdar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views31 pages

Aman Tarafdar XI - B

This document is a practical file for Computer Science by Aman Tarafdar, a student of Delhi Public School Newtown, for the batch 2024-25. It includes a certificate of authenticity, a table of contents listing various programming topics and algorithms, and source code examples for each topic. The practical work covers object-based programming, arrays, data structures, inheritance, recursion, and miscellaneous programs.

Uploaded by

rehantarafdar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 31

COMPUTER SCIENCE

PRACTICAL FILE
BATCH 2024-25
NAME : AMAN TARAFDAR
CLASS/ SECTION : XII - B
UNIQUE ID : 8071057
INDEX NUMBER :

1
CERTIFICATE OF AUTHENTICITY

This is to certify that Aman Tarafdar, UID No.

___________________ is a candidate of ISC 2025 of Delhi Public School


Newtown, has carried out the Computer Science practical work under the
supervision of Ms. Madhurima Acharya. This practical work is truly authentic
and not copied from any source.

Madhurima Acharya Sonali Sen


(HOD Computer Science) (Principal)

2
TABLE OF INDEX
TOPICS
S.NO PG NO.

OBJECT BASED PROGRAMS


Finding common elements of two arrays using objects
1.

Transposition of an array using objects


2.

Merging two arrays belong to different objects and finding


3. frequency of a number in the array

Time class to add two times and print the final time using
4. objects

Finding the difference between two matrices belong to different


5. objects

ARRAYS
Checking if the Matrix is symmetric or not. Also calculates the
6. sum of left and right diagonals of the matrix

Program to print boundary elements of a 2D array


7.

Program to determine if the given matrix Magic Square Matrix


8.

Program to find out saddle point Saddle Point in Matrix


9.

Program to check if the matrix is a Upper Triangular Matrix


10.

Program to generate Fibonacci sequence with strings


11.

Program to search and deleting a word from a sentence


12.

Program to decode a simple encrypted text


13.

3
Program to remove consecutive repeated characters by
14. replacing with its single occurrence

Program to calculate frequency of each alphabet present in the


15. string

DATA STRUCTURE
Program to implement Stack
16.

Program to implement LinearQ


17.

Program to implementing Dequeue


18.

Program to implementing CircularQ


19.

Program to implement Linked List


20.

Stack using Linked List


21.

Queue using Linked List


22.

INHERITANCE
Calculating salary of an employee by taking data from two
23. classes Employee and Salary

Program to calculate the salary of a daily wager based on


24. number of hours worked by inheriting classes Worker and
Wages
Program to find ranks of 50 students using inheritance of
25. classes Records and Rank

Program to compute monthly telephone charge by inheriting the


26. details from class Details into class Bill

Program to calculate and print perimeter and area of a


27. parallelogram using two classes Perimeter and Area

RECURSION

4
Finding out sum of the series recursively
28. x2/1! + x4/3!+x6/5!+….xn/(n-1)!

Finding out factorial of a number using recursion


29.

Finding Emirp Number using recursion


30.

Finding out frequency of words what begin with a vowel using


31. recursion

Number of times “and” and “an” comes in a sentence using


32. recursion

MISCELLANEOUS PROGRAMS
Program to perform Insertion Sort in a single dimension array
33.

Program to perform Merge Sort in a single dimension array


34.

Program to perform Quick Sort in a single dimension array


35.

QUESTION 1

5
ALGORITHM

SOURCE CODE

import java.util.Scanner;
6
class Collection {
private int[] ar; Collection commonCollection = new
private int len; Collection(k);
for (int i = 0; i < k; i++) {
public Collection() { commonCollection.ar[i] = temp[i];
this.len = 100; }
this.ar = new int[len];
} return commonCollection;
}
public Collection(int len) {
this.len = len; public void display() {
this.ar = new int[len]; System.out.println("Array elements:");
} for (int i = 0; i < len; i++) {
System.out.print(ar[i] + " ");
public void input() { }
Scanner sc = new Scanner(System.in); System.out.println();
System.out.println("Enter " + len + " }
elements:");
for (int i = 0; i < len; i++) { public static void main(String[] args) {
ar[i] = sc.nextInt(); Collection c1 = new Collection(10);
} Collection c2 = new Collection(20);
}
System.out.println("Input for Collection
public Collection common(Collection 1:");
other) { c1.input();
int[] temp = new int[len]; System.out.println("Input for Collection
int k = 0; 2:");
c2.input();
for (int i = 0; i < this.len; i++) {
for (int j = 0; j < other.len; j++) { Collection common = c1.common(c2);
if (this.ar[i] == other.ar[j]) { System.out.println("Common
temp[k++] = this.ar[i]; elements:");
break; common.display();
} }
} }
}

VARIABLE DESCRIPTION TABLE

7
OUTPUT

QUESTION 2
8
ALGORITHM

9
SOURCE CODE

import java.util.Scanner; }

class Collection { Collection commonCollection = new


private int[] ar; Collection(k);
private int len; for (int i = 0; i < k; i++) {
commonCollection.ar[i] = temp[i];
public Collection() { }
this.len = 100;
this.ar = new int[len]; return commonCollection;
} }

public Collection(int len) { public void display() {


this.len = len; System.out.println("Array elements:");
this.ar = new int[len]; for (int i = 0; i < len; i++) {
} System.out.print(ar[i] + " ");
}
public void input() { System.out.println();
Scanner sc = new Scanner(System.in); }
System.out.println("Enter " + len + "
elements:"); public static void main(String[] args) {
for (int i = 0; i < len; i++) { Collection c1 = new Collection(10);
ar[i] = sc.nextInt(); Collection c2 = new Collection(20);
}
} System.out.println("Input for Collection
1:");
public Collection common(Collection c1.input();
other) { System.out.println("Input for Collection
int[] temp = new int[len]; 2:");
int k = 0; c2.input();

for (int i = 0; i < this.len; i++) { Collection common = c1.common(c2);


for (int j = 0; j < other.len; j++) { System.out.println("Common
if (this.ar[i] == other.ar[j]) { elements:");
temp[k++] = this.ar[i]; common.display();
break; }
} }
}

10
VARIABLE DESCRIPTION TABLE

OUTPUT

QUESTION 3

11
ALGORITHM

12
SOURCE CODE

import java.util.Scanner; }
}
class Collection {
private int[] ar; public Collection common(Collection
private int len; other) {
int[] temp = new int[len];
public Collection() { int k = 0;
this.len = 100;
this.ar = new int[len]; for (int i = 0; i < this.len; i++) {
} for (int j = 0; j < other.len; j++) {
if (this.ar[i] == other.ar[j]) {
public Collection(int len) { temp[k++] = this.ar[i];
this.len = len; break;
this.ar = new int[len]; }
} }
}
public void input() {
Scanner sc = new Scanner(System.in); Collection commonCollection = new
System.out.println("Enter " + len + " Collection(k);
elements:"); for (int i = 0; i < k; i++) {
for (int i = 0; i < len; i++) { commonCollection.ar[i] = temp[i];
ar[i] = sc.nextInt(); }
13
return commonCollection; System.out.println("Input for Collection
} 1:");
c1.input();
public void display() { System.out.println("Input for Collection
System.out.println("Array elements:"); 2:");
for (int i = 0; i < len; i++) { c2.input();
System.out.print(ar[i] + " ");
} Collection common = c1.common(c2);
System.out.println(); System.out.println("Common
} elements:");
common.display();
public static void main(String[] args) { }
Collection c1 = new Collection(10); }
Collection c2 = new Collection(20);

VARIABLE DESCRIPTION TABLE

OUTPUT

14
QUESTION 4

15
ALGORITHM

SOURCE CODE

import java.util.Scanner;
public Collection() {
class Collection { this.len = 100;
private int[] ar; this.ar = new int[len];
private int len; }
16
commonCollection.ar[i] = temp[i];
public Collection(int len) { }
this.len = len;
this.ar = new int[len]; return commonCollection;
} }

public void input() { public void display() {


Scanner sc = new Scanner(System.in); System.out.println("Array elements:");
System.out.println("Enter " + len + " for (int i = 0; i < len; i++) {
elements:"); System.out.print(ar[i] + " ");
for (int i = 0; i < len; i++) { }
ar[i] = sc.nextInt(); System.out.println();
} }
}
public static void main(String[] args) {
public Collection common(Collection Collection c1 = new Collection(10);
other) { Collection c2 = new Collection(20);
int[] temp = new int[len];
int k = 0; System.out.println("Input for Collection
1:");
for (int i = 0; i < this.len; i++) { c1.input();
for (int j = 0; j < other.len; j++) { System.out.println("Input for Collection
if (this.ar[i] == other.ar[j]) { 2:");
temp[k++] = this.ar[i]; c2.input();
break;
} Collection common = c1.common(c2);
} System.out.println("Common
} elements:");
common.display();
Collection commonCollection = new }
Collection(k); }
for (int i = 0; i < k; i++) {

VARIABLE DESCRIPTION TABLE

17
OUTPUT

QUESTION 5

18
ALGORITHM

19
SOURCE CODE

import java.util.Scanner; }

class Collection { Collection commonCollection = new


private int[] ar; Collection(k);
private int len; for (int i = 0; i < k; i++) {
commonCollection.ar[i] = temp[i];
public Collection() { }
this.len = 100;
this.ar = new int[len]; return commonCollection;
} }

public Collection(int len) { public void display() {


this.len = len; System.out.println("Array elements:");
this.ar = new int[len]; for (int i = 0; i < len; i++) {
} System.out.print(ar[i] + " ");
}
public void input() { System.out.println();
Scanner sc = new Scanner(System.in); }
System.out.println("Enter " + len + "
elements:"); public static void main(String[] args) {
for (int i = 0; i < len; i++) { Collection c1 = new Collection(10);
ar[i] = sc.nextInt(); Collection c2 = new Collection(20);
}
} System.out.println("Input for Collection
1:");
public Collection common(Collection c1.input();
other) { System.out.println("Input for Collection
int[] temp = new int[len]; 2:");
int k = 0; c2.input();

for (int i = 0; i < this.len; i++) { Collection common = c1.common(c2);


for (int j = 0; j < other.len; j++) { System.out.println("Common
if (this.ar[i] == other.ar[j]) { elements:");
temp[k++] = this.ar[i]; common.display();
break; }
} }
}

20
VARIABLE DESCRIPTION TABLE

OUTPUT

21
QUESTION 6

22
ALGORITHM

23
SOURCE CODE

import java.util.Scanner; }

class Collection { public Collection common(Collection


private int[] ar; other) {
private int len; int[] temp = new int[len];
int k = 0;
public Collection() {
this.len = 100; for (int i = 0; i < this.len; i++) {
this.ar = new int[len]; for (int j = 0; j < other.len; j++) {
} if (this.ar[i] == other.ar[j]) {
temp[k++] = this.ar[i];
public Collection(int len) { break;
this.len = len; }
this.ar = new int[len]; }
} }

public void input() { Collection commonCollection = new


Scanner sc = new Scanner(System.in); Collection(k);
System.out.println("Enter " + len + " for (int i = 0; i < k; i++) {
elements:"); commonCollection.ar[i] = temp[i];
for (int i = 0; i < len; i++) { }
ar[i] = sc.nextInt();
} return commonCollection;

24
} System.out.println("Input for Collection
1:");
public void display() { c1.input();
System.out.println("Array elements:"); System.out.println("Input for Collection
for (int i = 0; i < len; i++) { 2:");
System.out.print(ar[i] + " "); c2.input();
}
System.out.println(); Collection common = c1.common(c2);
} System.out.println("Common
elements:");
public static void main(String[] args) { common.display();
Collection c1 = new Collection(10); }
Collection c2 = new Collection(20); }

VARIABLE DESCRIPTION TABLE

OUTPUT

25
QUESTION 7

ALGORITHM

26
SOURCE CODE

import java.util.Scanner; }

class Collection { Collection commonCollection = new


private int[] ar; Collection(k);
private int len; for (int i = 0; i < k; i++) {
commonCollection.ar[i] = temp[i];
public Collection() { }
this.len = 100;
this.ar = new int[len]; return commonCollection;
} }

public Collection(int len) { public void display() {


this.len = len; System.out.println("Array elements:");
this.ar = new int[len]; for (int i = 0; i < len; i++) {
} System.out.print(ar[i] + " ");
}
public void input() { System.out.println();
Scanner sc = new Scanner(System.in); }
System.out.println("Enter " + len + "
elements:"); public static void main(String[] args) {
for (int i = 0; i < len; i++) { Collection c1 = new Collection(10);
ar[i] = sc.nextInt(); Collection c2 = new Collection(20);
}
} System.out.println("Input for Collection
1:");
public Collection common(Collection c1.input();
other) { System.out.println("Input for Collection
int[] temp = new int[len]; 2:");
int k = 0; c2.input();

for (int i = 0; i < this.len; i++) { Collection common = c1.common(c2);


for (int j = 0; j < other.len; j++) { System.out.println("Common
if (this.ar[i] == other.ar[j]) { elements:");
temp[k++] = this.ar[i]; common.display();
break; }
} }
}

27
VARIABLE DESCRIPTION TABLE

OUTPUT

QUESTION 8

28
ALGORITHM

SOURCE CODE

import java.util.Scanner;
public Collection() {
class Collection { this.len = 100;
private int[] ar; this.ar = new int[len];
private int len; }
29
commonCollection.ar[i] = temp[i];
public Collection(int len) { }
this.len = len;
this.ar = new int[len]; return commonCollection;
} }

public void input() { public void display() {


Scanner sc = new Scanner(System.in); System.out.println("Array elements:");
System.out.println("Enter " + len + " for (int i = 0; i < len; i++) {
elements:"); System.out.print(ar[i] + " ");
for (int i = 0; i < len; i++) { }
ar[i] = sc.nextInt(); System.out.println();
} }
}
public static void main(String[] args) {
public Collection common(Collection Collection c1 = new Collection(10);
other) { Collection c2 = new Collection(20);
int[] temp = new int[len];
int k = 0; System.out.println("Input for Collection
1:");
for (int i = 0; i < this.len; i++) { c1.input();
for (int j = 0; j < other.len; j++) { System.out.println("Input for Collection
if (this.ar[i] == other.ar[j]) { 2:");
temp[k++] = this.ar[i]; c2.input();
break;
} Collection common = c1.common(c2);
} System.out.println("Common
} elements:");
common.display();
Collection commonCollection = new }
Collection(k); }
for (int i = 0; i < k; i++) {

VARIABLE DESCRIPTION TABLE

30
OUTPUT

31

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy