Computer Science Class 11 Project
Computer Science Class 11 Project
Computer Science Class 11 Project
_________________ __________________
Internal Examiner External Examiner
Approval Approval
2
ABOUT MYSELF
I am SK RISHAD RAHMAN, and I am currently a student in the 11th
grade. Life as a student has been wonderful so far and would expect to
be wonderful when I go to the college for my further studies and become
a good engineer. I have experienced both triumphs and challenges
during my school life, which have helped to shape me into the person I
am now.
3
ACKNOWLEDGEMENT
I want to be really grateful to my computer teacher Mrs. Fancy
Roy Choudhury and our Council ISC for providing such an
informative project to us. While doing this project, it helped me
a lot as all of my doubts were getting cleared as I was
progressing in this project.
I also thank to my fellow friends, parents and my tuition
teacher for helping me in doing this project. They motivated me,
guided me and helped me all through the project and complete
in limited time.
I have done this project not only for marks but to increase my
knowledge in this particular subject.
Last but not least once again I want to thank to all who helped
me, and motivated me and guided me while doing my project.
SK RISHAD RAHMAN
CLASS ‘XI’ SCIENCE.
4
Table of Contents
1. Introduction…………………………………………………… 6
2. Programs……………………………………………………….. 11
3. Conclusion……………………………………………………… 37
4. Bibliography…………………………………………………… 38
5
INTRODUCTION
Introduction To Object Oriented Programming.
Object-oriented programming aims to implement real-world
entities like inheritance, hiding, polymorphism, etc in
programming. The main aim of OOP is to bind together the data
and the functions that operate on them so that no other part of the
code can access this data except that function. Types of high level
languages are:
a. Procedure-Oriented.
b. Object Oriented.
6
PRINCIPLES OF OBJECT ORIENTED PROGRAMING (OOP):
Data Abstraction: Objects in an OOP language provide an
abstraction that hides the internal implementation details.
Similar to the coffee machine in your kitchen, you just need to
know which methods of the object are available to call and which
input parameters are needed to trigger a specific operation.
Encapsulation: In object-oriented computer programming (OOP)
languages, the notion of encapsulation (or OOP Encapsulation)
refers to the bundling of data, along with the methods that
operate on that data, into a single unit. Many programming
languages use encapsulation frequently in the form of classes.
Inheritance: When a class derives from another class. The child
class will inherit all the public and protected properties and
methods from the parent class. In addition, it can have its own
properties and methods. An inherited class is defined by using
the extends keyword.
Polymorphism: Polymorphism is one of the core concepts of
object-oriented programming (OOP) and describes situations in
which something occurs in several different forms. In computer
7
science, it describes the concept that you can access objects of
different types through the same interface.
8
Types of Class and Objects:
1. Real World Class and Objects: a car is an object. The car
has attributes, such as weight and color, and methods,
such as drive and brake. A Class is like an object
constructor, or a "blueprint" for creating objects.
2. Software Class and Objects: A class is a blueprint from
which you can create the instance, i.e., objects. An object
is the instance of the class, which helps programmers to
use variables and methods from inside the class. A class is
used to bind data as well as methods together as a single
unit. Object acts like a variable of the class.
9
Some Meaningful Terms of Object and Class:
Class is an object factory: A class is used to create similar
objects and possess different characteristics and common
behaviors. Hence, class is called an object factory.
Object is instance of a class: The data members declared
within a class are also known as instance variables. When
an object of a class is created, it includes instance variable
described within the class. This is the reason that object is
called as instance of a class.
Class is a user defined data type: When user creates a
class it becomes a data type for his program. Thus class is
referred to as a user defined data type. This data type
includes different primitive types such as int, float, char,
etc. Hence, it is also said to Composite Data Types.
PROGRAMMES
10
1. Write a program to accept any three- letter word and print all
the probable three- letter combinations. No letter should
repeat in the output.
Sample Input: TOP
Sample Output: The required combinations of the word:
TOP, TPO, OPT, OTP, PTO, POT
import java.util.*;
String str;
int i,j,p,k;
str=sc.nextLine();
p=str.length();
for(i=0;i<p;i++)
for(j=0;j<p;j++)
11
for(k=0;k<p;k++)
System.out.print(str.charAt(i)+""+str.charAt(j)+""+str.charAt(k));
System.out.println();
import java.util.*;
public class EvenSuccessor
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number: ");
int num = sc.nextInt();
int orgNum = num;
int prod = 1;
while (num != 0)
{
int digit = num % 10;
num /= 10;
if (digit % 2 == 0)
prod = prod * (digit + 1);
}
if (prod == 1)
System.out.println("No even digits in " + orgNum);
else
System.out.println("Product of even digits successors is " + prod);
}
}
13
3. Write a program to input a number and check whether it is
'Magic Number' or not. Display the message accordingly.
A number is said to be a magic number if the eventual sum of
digits of the number is one.
Sample Input : 55
Then, 5 + 5 = 10, 1 + 0 = 1
Sample Output: Hence, 55 is a Magic Number.
Similarly, 289 is a Magic Number.
import java.util.*;
public class MagicNumber
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter number to check: ");
int num = sc.nextInt();
int n = num;
while (n > 9)
{
int sum = 0;
while (n != 0)
{
int d = n % 10;
14
n /= 10;
sum += d;
}
n = sum;
}
if (n == 1)
System.out.println(num + " is Magic Number");
else
System.out.println(num + " is not Magic Number");
}
}
4. Write a program to find the sum of the given series to ‘n’
terms by using function name sum(int). Write the main
program to display the sum of the series.
S= (1*2) + (2*3) + (3*4) +------------------------------------- to ‘n’
terms.
import java.util.*;
public class Series
{
int sum(int a)
{
int i,s=0;
for(i=1;i<a;i++)
s=s+(i*(i+1));
return(s);
}
public static void main()
{
Scanner sc=new Scanner(System.in);
int p,n;
System.out.println("Enter the value of n");
n=sc.nextInt();
Series ob=new Series();
15
p=ob.sum(n);
System.out.println("The sum of the series is "+p);
}
}
import java.util.*;
public class Prime
{
int check(int n)
{
int i,c=0,f=0;
for(i=1;i<=n;i++)
{
if(n%i==0)
c=c+1;
}
if(c==2)
f=1;
return(f);
16
}
public static void main()
{
int a,k;
Scanner sc=new Scanner(System.in);
System.out.println("Enter your number");
a=sc.nextInt();
Prime ob= new Prime();
k=ob.check(a);
if(k==1)
System.out.println(a+"is a prime number");
else
System.out.println(a+"is not a prime number");
}
}
17
OUTPUT OF THE PROGRAM:
18
6. Write a program by using a class with the following
specifications:
Class name : Prime
Data members/instance variables : int n
Member Methods :
Prime() : default constructor to initialize n
Void input(int x) : to assign ‘n’ with ‘x’
Void display() : to check whether the number is prime or not.
19
}
STEP 2:
STEP 3:
20
7. Write a program in java to accept an array from the user and
insert an element given by the user in the position given by the
user.
import java.util.*;
public class Insert
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int i,n,ele,pos;
int arr[]=new int[10];
System.out.println("Enter number of array elements");
n=sc.nextInt();
System.out.println("Enter array elements");
for(i=0;i<n;i++)
arr[i]=sc.nextInt();
System.out.println("Enter the element to be inserted");
ele=sc.nextInt();
System.out.println("Enter position of insertion");
pos=sc.nextInt();
for(i=n-1;i>=pos;i--)
arr[i+1]=arr[i];
arr[pos]=ele;
n++;
System.out.println("Array elememts after insertion");
for(i=0;i<n;i++)
System.out.println(arr[i]);
}
}
21
OUTPUT OF THE PROGRAM:
import java.util.*;
public class Deletion
{
public static void main()
{
int i,n,pos;
int arr[]=new int[10];
Scanner sc=new Scanner(System.in);
System.out.println("Enter number of array elements");
n=sc.nextInt();
System.out.println("Enter array elements");
for(i=0;i<n;i++)
arr[i]=sc.nextInt();
System.out.println("Enter position of element to be deleted");
22
pos=sc.nextInt();
for(i=pos+1;i<n;i++)
arr[i-1]=arr[i];
n--;
System.out.println("Array elements after deletion");
for(i=0;i<n;i++)
System.out.println(arr[i]);
}
}
import java.util.*;
public class Merging
{
public static void main()
{
int i,n,m,p,pos;
Scanner sc =new Scanner(System.in);
System.out.println("Enter number of array elements in array arr1");
23
n=sc.nextInt();
System.out.println("Enter number of array elements in array arr2");
m=sc.nextInt();
System.out.println("Enter number of elements in merged array arr3");
p=sc.nextInt();
int arr1[]=new int[n];
int arr2[]=new int[m];
int arr3[]=new int[p];
System.out.println("Enter elements in array arr1");
for(i=0;i<n;i++)
arr1[i]=sc.nextInt();
System.out.println("Enter elements in array arr2");
for(i=0;i<m;i++)
arr2[i]=sc.nextInt();
for(i=0;i<n;i++)
arr3[i]=arr1[i];
for(i=0;i<m;i++)
arr3[n+i]=arr2[i];
System.out.println("Array elements after merging");
for(i=0;i<p;i++)
System.out.println(arr3[i]);
}
}
24
10. Write a program in java to store different numbers in 4x4
matrix in a Double Dimensional Array. Display the highest and
the lowest number among the stored number in the matrix.
import java.util.*;
public class highLow
{
public static void main()
{
int i,j,max=0,min=0;
int num[][]=new int [4][4];
Scanner sc=new Scanner(System.in);
System.out.println("Enter the numbers in the 4x4 matrix:");
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
num[i][j]=sc.nextInt();
}
}
System.out.println("The elements of 4x4 matrix are:");
for(i=0;i<4;i++)
25
{
for(j=0;j<4;j++)
{
System.out.print(num[i][j]+ " ");
}
}
System.out.println();
min=num[0][0];max=num[0][0];
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
if(min>num[i][j])
min=num[i][j];
if(max<num[i][j])
max=num[i][j];
}
}
System.out.println("The highest number :" +max);
System.out.println("The lowest number :" +min);
}
}
OUTPUT OF THE PROGRAM:
import java.util.*;
public class LeftRight
{
public static void main()
{
int i,j,ld=0,rd=0,k=3;
int num[][]=new int[4][4];
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number in 4x4 matrix :");
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
num[i][j]=sc.nextInt();
}
}
System.out.println("The elments of 4x4 matrix are:");
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
System.out.print(num[i][j]+" ");
}
System.out.println();
}
for(i=0;i<4;i++)
{
ld=ld+num[i][i];
}
for(j=0;j<4;j++)
27
{
rd=rd+num[j][k];
k=k-1;
}
System.out.println("The sum of left diagonal :"+ld);
System.out.println("The sum of right diagonal :"+rd);
System.out.println("The diff. between left and right diagonal : "
+(ld-rd));
}
}
OUTPUT OF THE PROGRAM:
import java.util.*;
28
public class Addition
{
int sum(int a,int b)
{
int c;
c=a+b;
return(c);
}
public static void main()
{
int m,n,k;
Scanner sc=new Scanner(System.in);
Addition ob=new Addition();
System.out.println("Enter two numbers");
m=sc.nextInt();
n=sc.nextInt();
k=ob.sum(m,n);
System.out.println("The sum of two numbers :"+k);
}
}
OUTPUT OF THE PROGRAM:
29
Void input (int a, int b) : to assign ‘cp’ with ‘m’ and ‘sp’ with
‘n’
Void display () : to calculate and display either profit percent
(pp) or loss percent (lp)
30
}
STEP 2:
31
STEP 4(Loss output):
import java.util.*;
public class Npower
{
int power(int n,int p)
{
if(p==0)
return(1);
else
return(n*power(n,p-1));
}
public static void main()
{
Scanner sc=new Scanner(System.in);
int num,p,ans;
System.out.println("Enter the base value");
num=sc.nextInt();
System.out.println("Enter power of the base value");
32
p=sc.nextInt();
Npower ob=new Npower();
ans=ob.power(num,p);
System.out.println(num+" to the power "+ p + " is "+ans);
}
}
OUTPUT OF THE PROGRAM:
33
recursive function to return Tth Fibonacci element, where T is
the term number.
import java.util.*;
if(num==1)
return(0);
else if(num==2)
return(1);
else if(num>2)
return(fiboseries(num-1)+fiboseries(num-2));
else
return(-1);
int n,p=0;
n=sc.nextInt();
34
Fseries ob=new Fseries();
for(int i=1;i<=n;++i)
p=ob.fiboseries(i);
}}
------x------
CONCLUSION
As you have seen, computers are an exciting addition to the writing
process. Computers are a resource, just as there are many different
writing resources, and should be used as such. They are an undisputedly
important tool to the writer, but you cannot complete a project with just
one tool.
36
BIBLIOGRAPHY
THEORY: APC UNDERSTANDING COMPUTER SCIENCE ISC
CLASS 11 and ‘GOOGLE’.
PROGRAMS: APC UNDERSTANDING COMPUTER SCIENCE ISC
CLASS 11.
‘KNOWLEDGEBOAT’ FROM ‘GOOGLE’.
37
38