Submitted To: Mrs. Meenakshi Negi Submitted By: Parth Sharma X-A R.NO-26
Submitted To: Mrs. Meenakshi Negi Submitted By: Parth Sharma X-A R.NO-26
MEENAKSHI NEGI
SUBMITTED BY: PARTH SHARMA
X-A
R.NO-26
ACKNOWLEDGEMENT
I have taken much efforts in this
project, however it would not have
been possible without the kind support
and help of many individuals. I would
like to extend my sincere thanks to all
of them.
PAGE 1
INDEX
S.NO CONTENT PAGE NO.
1 INTRODUCTION 1
2 IT ICON-JAMES GOSLING 2
3 SECTION A- DEFINITION 3
4 SECTION B- DIFFERENCES 4,5
5 SECTION C- PROGRAMS 6-12
6 CONCLUSION 13
7 BIBLIOGRAPHY 14
PAGE 2
INTRODUCTION
A computer is a multipurpose electronic device
that can recieve, process and store data. They
are used as tools in every part of society
together with the internet. Computers
nowadays are complex; there are lot of different
components inside them, and they all serve
different purposes. They all need to work
together for the computer to work; knowing how
a computer works makes it easier to use a
computer by being able to understand how a
computer will respond.
PAGE 3
IT ICON -:
JAMES GOSLING
James Arthur Gosling is a Canadian computer
scientist, best known as the founder and lead
designer behind the Java programming language.
James Gosling was born on 19 May, 1955 in Alberta,
Canada.
PAGE 4
Advisor for Eucalptus, and is a board member of
DIRTT Environmental Solutions.
PAGE 5
SECTION-A
DEFINITION -:
1-: CLASS-: Class is a blue print or a prototype that
is used to define variables and methods
common to all objects of a certain kind.
PAGE 6
SECTION – B
DIFFERNCES-:
1-: WHILE LOOP DO WHILE LOOP
1-It is entry control loop. 1- It is exit control loop
2- Condition is checked at the beginning of 2- It is checked in the end of the
a loop. loop.
3 - If the condition is false the loop will not be 3- If the condition is false loop will be
executed even once. executed once.
4- It is never terminated with semi-colon. 4- It is terminated with semi-colon.
PAGE 7
4-: PREFIX POSTFIX
1-Operator is placed before operand. 1-Operator is placed after
operand.
PAGE 8
parameter. the memory location of actual
parameter.
2-Changes made to the formal parameter 2-Changes made to the formal
parameter
do not affect the actual parameter. effects the state of actual parameter.
3-The actual parameters in the function 3-The actual parameters for the
function
the data type is of primitive type. i.e. the objects of given class type are
passed as parameters.
PAGE 9
SECTION-C
PROGRAMS-:
1-Finding the occurrence of selective text with in a string.
SOLUTION-:
class Subtext
{
public static void main(String str, String sub)
{
int x = str.length();
int y = sub.length();
int count = 0;
String temp;
for(int i=y; i<=x; i++)
{
temp = str.substring(i-y,i);
System.out.println(temp);
if(temp.equals(sub))
{
count++;
}
}
System.out.println(count);
}
}
PAGE 10
2-Program to reverse each word in a string.
SOLUTION-:
class Reveach
int p = 0;
int l = str.length();
for(int i=0;i<l;i++)
int x = (int)str.charAt(i);
if(x==32 || i==l-1)
{ for(int j=i;j>=p;j--)
{System.out.println(str.charAt(j));
p = i;
PAGE 11
3-Program to display whether the given string is a palindrome.
SOLUTION-:
class Pro1
int x = str.length();
for(int i=(x-1);i>=0;i--)
if( rev.equalsIgnoreCase(str))
else
PAGE 12
4-Write a program of binary search.
SOLUTION-:
class Bsearch
{ static void binarysearch(int a[], int val)
{
int lb = 0;
int ub = a.length -1;
int pos = -1;
int mid;
while(pos == -1 && (ub>=lb))
{ mid = (ub+lb)/2;
if (a[mid]==val)
{
pos = mid;
}
if(a[mid]<val)
{
lb = mid+1;
}
else
{
ub = mid+1;
}
}
if(pos == -1)
System.out.println("Element is not present in the list");
else
System.out.println("Element is at position no."+(pos+1));
}
PAGE 13
}
PAGE 14
5-Write a program to find all prime numbers between 1 to 100.
SOLUTION-:
class Prime
{
static booleanprime(int num)
{
int c = 0;
for(int i=1;i<=num;i++)
{
if(num%i ==0)
{
c++;
}
}
if(c == 2)
return true;
else
return false; //function returning boolean
value
}
public static void main()
{
for(int i=0;i<=100;i++)
{
if(prime(i)) //calling subfunction prime() 100
times
{
System.out.println(i); //if i is prime it will print
PAGE 15
}
}
}
}
PAGE 16
6-1! + 2! + 3! +………n!
SOLUTION-:
class P28
int p = 1;
for(int i=1;i<=x;i++)
p = p*i;
return p;
int sum = 0;
}
PAGE 17
PAGE 18
7-1 + 2/2! + 3/3! + 4/4!......+ n/n!
SOLUTION-:
class P29
{
static int fact(int x) //fact method returns factorial for
given number
{
int p = 1;
for(int i=1;i<=x;i++)
{
p = p*i;
}
return p;
}
static void series(int n)
{
double sum = 0;
for(int i=1;i<=n;i++)
{
sum = sum + (double)(i/fact(i));
}
System.out.println("1+2/2!+3/3!+4/4!......+n/n ="+ sum);
}
}
PAGE 19
CONCLUSION
I felt very interesting in doing this project. It
gave a lot of knowledge while completing
this project.
I came to know about the great IT ICON
“JAMES GOSLING” whose works are very
much inspiring and full of knowledge like
“java”. I understood how to make programs
in java. The definitions and differences will
help me in my exams. By learning them I
can understand the lessons better.
So thankyou mam for giving me this project
which made my summer vacations
interesting and full of fun.
PAGE 20
BIBLIOGRAPHY
SITES-: www.wikipedia.com
www.google.com
BOOKS AUTHORS
TOTAL COMPUTER RAVI KHURANA
APPLICATIONS. P.S. LATIKA
PAGE 21