0% found this document useful (0 votes)
12 views

Computer Project - Devansh

Uploaded by

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

Computer Project - Devansh

Uploaded by

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

1

ASSESSMENT SHEET

Name :- Devansh Shukla


Class :- X

Section :- B

Roll No :- 20

Internal Examiner Signature :-

External Examiner Signature :-


2

ACKNOWLEDGEMENT
The success and final outcome of this project required a lot of
guidance and assistance from many people and I am extremely
privileged to have got this all along the completion of my project. All
that I have done is only due to such supervision and assistance and I
would not forget to thank them.

I respect and thank Mr.D.N Rai Sir, for providing me an opportunity to


do this project and giving us all support and guidance which made me
complete the project duly. I am extremely thankful to him providing
such a nice support and guidance even after having his busy schedule
managing the corporate affairs.

I owe my deep gratitude to my project guide i.e. none other than my


friends, who took keen interest in my project work and guided me all
along, till the completion of my project work by providing all the
necessary information by developing a good system.

I would not forget to remember my parents and siblings for their


encouragement and more over for their timely support and guidance till
the completion of this project.

At last I would also like to thank the examiner for taking pains to go
through this project and I would also welcome suggestions for
improvement. -Devansh Shukla
3

INDEX
S.no Category Name of Page
Program No.(s)
* Arrays
1 Write a program
to enter 10
numbers in an
array and print the
sum of all even
numbers.
2 Write a program
to enter 10
numbers in an
array and print the
sum of the
numbers at even
positions.
3 Write a program
to enter 10
numbers in an
array and reverse
the array
4

elements without
using another
array.
4 Write a program
to input 15
numbers in an
Array and find the
average of the
odd numbers in
the inputed array.
5 Write a program
to enter 10
numbers in an
array and search
the given number
using linear
search technique.
6 Write a program
to enter 10
numbers in an
array and search
the given number
using binary
search technique.
7 Write a program
to input 16
numbers in 4
rows and 4
columns of the
Array of size 5x5.
5

Then find the sum


of each row and
each column and
store the result in
the corresponding
rows and columns
of the Array and
then print the
resulting matrix.
* String
8 Write a program
to accept a String
and convert the
String into
UpperCase and
also count the
number of double
letter sequence.
9 Write a program
to input a String
and print the
String with
UpperCase and
LowerCase letters
reversed.
10 Write a program
to input a String
and count the
number of vowels
6

in the String.
11 Write a program
to input any String
and convert the
String into Piglatin
Form.
12 Write a program
to input any String
and print only the
Palindrome words
of the String.
13 Write a program
to input a string in
the provided
manner.
14 Write a program
by considering the
following
statement to
change 26 to 15,
January to
August, Republic
to Independence,
and finally print
the updated
String, “January
26 is celebrated
as the Republic
Day of India”.
7

* Primary
Programs
15 Write a program
to input any
number and print
whether it is a
prime number or
not.
16 Write a program
to print the
following Pattern
17 Write a program
to print the
following
Fibonacci Series
18 Write a program
to input any
number and
check whether it
is automorphic or
not
19 Write a program
to input any age
and check
whether the
person is a Senior
Citizen or not.
20 Write a program
to input any
8

number and
check whether it
is a triple digit
number or not.

COMPUTER PROGRAMS
Arrays
7 Programs including Single Dimension Array, Linear
Search, Binary Search and Double Dimension Array

Ques 1) Write a program to input 10 numbers in an array and find the


sum of all even numbers.
import java.util.*;
9

class sum
{
public static void main()
{
int a[] = new int[10];
int i, s=0;
Scanner sc = new Scanner(System.in);
System.out.println(“Enter 10 Numbers”);
for( i=0 ; i<=9 ; i++ )
{
a[i] = sc.nextInt();
}
for( i=0 ; i<=9 ; i++ )
{
if( a[i] % 2 == 0 )
s = s + a[i];
}
System.out.println( “Sum of all the even numbers is” + s );
}
}
10

VARIABLE DESCRIPTION TABLE

S. VARIABLE DESCRIPTION DATATPE


No.
1 i Looping Variable Integer
2 s Variable for storing the sum of all even Integer
numbers from the inputed Array
3 a[] Array for storing values Integer
11

Ques 2) Write a program to input 10 numbers in an array and find the


sum of all numbers at even position.
import java.util.*;
class sum2
{
public static void main()
{
int a[] = new int[10];
int i, s=0;
Scanner sc = new Scanner(System.in);
System.out.println(“Enter 10 numbers”);
for( i=0 ; i<=9 ; i++)
{
a[i] = sc.nextInt();
}
for( i=0 ; i<=9 ; i++)
{
if( a[i] % 2 != 0 )
s = s + a[i];
}
System.out.println( “Sum of numbers at even position is”+ s );
}
}
12

VARIABLE DESCRIPTION TABLE

S. VARIABLE DESCRIPTION DATATYPE


No
1 i Looping Variable Integer
2 s Variable for storing the sum of Integer
numbers at even position of the
inputed Array
3 a[] Array for storing values Integer
13

Ques 3) Write a program to input 10 numbers in an array and find the


average of odd numbers.
import java.util.*;
class average
{
public static void main()
{
int a[] = new int[10];
int I, s=0, c=0;
double avg;
Scanner s = new Scanner(System.in);
System.out.println(“Enter 10 numbers”);
for(i=0 ; i<=9 ; i++)
{
a[i] = sc.nextInt();
}
for(i=0 ; i<=9 ; i++)
{
if (a[i] % 2!= 0)
{
s = s+a[i];
c++;
}
14

avg = s/c;
System.out.print(“The average of odd numbers of the Array
is”+avg”);
}
}

VARIABLE DESCRIPTION TABLE

S. VARIABLE DESCRIPTION DATATYPE


No
1 i Looping Variable Integer
2 s Variable for calculating the sum of odd Integer
numbers of the inputed Array
3 c Counting Variable Integer
4 avg Variable for calculating the average of Double
the inputed Array
5 a[i] Array for storing values Integer
15

Ques 4) Write a program to enter 10 numbers in an array and reverse


the array elements without using another array.
import java.util.*;
class reverse
{
public static void main()
{
int a[] = new int[10];
int i, j, t;
Scanner sc = new Scanner(System.in);
System.out.println(“Enter 10 numbers”);
for( i=0 ; i<=9 ; i++)
{
a[i] = sc.nextInt();
}
for(i=0 , j=9 ; i<=j ; i++ , j--)
{
t = a[i];
a[i] = a[j];
a[j] = t;
}
for(i=0 ; i<=9 ; i++)
{
16

System.out.print(“Reversed Array elements are” + a[i]);


}
}
}

VARIABLE DESCRIPTION TABLE

S. VARIABLE DESCRIPTION DATATPE


No
1 i Looping Variable Integer
2 j Looping Variable Integer
3 t Temporary Variable for reversing the Integer
Array values
4 a[] Array for storing values Integer
17

Ques 5) Write a program to enter 10 numbers in an array and search


the given number by linear search technique.
import java.util.*;
class linear
{
public static void main()
{
int a[] = new int[10];
int i, n, f=0;
Scanner sc = new Scanner(System.in);
System.out.println(“Enter 10 numbers”);
for(i=0 ; i<=9 ; i++)
{
a[i] = sc.nextInt();
}
System.out.println(“Enter any number to be searched”);
n = sc.nextInt();
for(i=0 ; i<=9; i++)
{
if(n == a[i])
{
f = 1;
}
18

}
if(f == 1)
System.out.println(“Number exists and the position is” + (i+1));
else
System.out.println(“Number does not exist”);
}
}

VARIABLE DESCRIPTION TABLE

S. VARIABLE DESCRIPTION DATATYPE


No
1 i Looping Variable Integer
2 n Variable to enter the number for Integer
searching in the inputed array
3 f Flag Variable Integer
4 a[] Array for storing values Integer
19

Ques 6) Write a program to enter 10 numbers in an array in a specific


order and search the given number by Binary search technique.
import java.util.*;
class binary
{
public static void main()
{
Int a[] = new int[10];
int i, n, f=0, l=0, u=9, m;
Scanner sc = new Scanner(System.in);
System.out.println(“Enter 10 numbers in an array in ascending
order”);
for(i=0 ; i<=9 ; i++)
{
a[i] = sc.nextInt();
}
System.out.println(“Enter a number to be searched”);
n = sc.nextInt();
while(l<=u)
{
m = (l+u)/2;
if( n == a[m])
{
20

f=1;
break;
}
else
if( n>a[m])
l = m+1;
else
if( n<a[m] )
u = m-1;
}
if (f==1 )
System.out.println(“Number exists”);
else
System.out.println(“Number does not exist”);
}
}
21

VARIABLE DESCRIPTION TABLE

S. VARIABLE DESCRIPTION DATATYPE


No
1 i Looping Variable Integer
2 n Variable to enter the number to be Integer
searched in the inputed Array
3 f Flag Variable Integer
4 l Variable to enter the Lower Limit of the Integer
Array
5 u Variable to enter the Upper Limit of the Integer
Array
6 m Variable to find the Middle Term of the Integer
inputed Array
7 a[] Array for storing values Integer
22

Ques 7) Write a program to input 16 numbers in 4 rows and 4


columns in a matrix of 5x5. Then find the sum of each row and each
column and store the result in the corresponding rows and columns
and print the resulting matrix.
import java.util.*;
class array
{
public static void main()
{
int a[][] = new int [5][5];
int i, j, s1 =0, s2=0 ; s3=0;
Scanner sc = new Scanner(System.in);
System.out.println(“Enter 16 numbers”);
for(i=0 ; i<=3; i++)
{
for(j=0 ; j<=3 ; j++)
{
a[i][j] = sc. nextInt();
}
23

}
for(i=0 ; i<=3 ; i++)
{
s1=0;
s2=0;
for(j=0 ; j<=3; j++)
{
s3 = s3+a[i][j];
s2 = s2+a[i][j];
s1 = s1+a[i][j];
}
a[i][j] = s2;
a[j][i] = s1;
}
for(i=0 ; i<=4 ; i++)
{
for(j=0 ; j<=4 ; j++)
System.out.print(“The resulting matrix is”+a[i][j]);
}
System.out.println();
}
}
24

VARIABLE DESCRIPTION TABLE

S. VARIABLE DESCRIPTION DATATYPE


No
1 i Looping Variable Integer
2 j Looping Variable Integer
3 s1 Variable for calculating and storing the Integer
sum of the inputed Array
4 s2 Variable for calculating and storing the Integer
sum of the inputed Array
5 s3 Variable for calculating and storing the Integer
sum of the inputed Array
6 a[][] Array for storing values Integer
25

String
7 Programs including String Manipulation

Ques 8) Write a program to accept any string and convert the string
into uppercase also count the number of double letter sequence.
class uppercase
{
public static void main(String x)
{
int I, l, c=0;
char ch1, ch2;
x = x.toUpperCase()
l = x.length();
for(i=0 ; i<=l-2 ; i++)
26

{
ch1 = x.charAt(i);
ch2 = x.charAt(i+1);
if(ch1==ch2)
c++;
}
System.out.println(“No. of double lettered sequence is”+c);
}
}

VARIABLE DESCRIPTION TABLE

S. VARIABLE DESCRIPTION DATATYPE


No
1 x Variable to input a String String
2 i Looping Variable Integer
3 l Variable to find the length of the Integer
inputed String
4 c Counting Variable Integer
5 ch1 Variable to extract the character of the Char
inputed String
6 ch2 Variable to extract the character of the Char
inputed String
27

Ques 9) Write a program to enter a String and print the String with
UpperCase and LowerCase letters reversed.
Class String
{
public static void main(String x)
{
int I, l;
char ch;
String y = “”;
l = x.length();
for(i=0 ; i<=l-1 ; i++)
{
ch = x.charAt(i);
if(Character.isLowerCase(ch))
ch = Character.toUpperCase(ch);
else
ch = Character.toLowerCase(ch);
28

y = y+ch;
}
y = y.trim();
System.out.print(“New String is”+y);
}
}

VARIABLE DESCRIPTION TABLE

S.No VARIABLE DESCRIPTION DATATYPE


1 x Variable to input a string String
2 i Looping Variable Integer
3 l Variable to find the length of the Integer
inputed String
4 ch Variable to extract character from the char
inputed String
5 y Variable to input and print the String
converted String
29

Ques 10) Write a program to input a String and count the number of
vowels in it.
class vowels
{
public static void main(String x)
{
int i, l, c=0;
char ch;
String y = “AEIOUaeiou”;
l = x.length();
for(i=o ; i<=l-1 ; i++)
{
ch = x.charAt(i);
if(y.indexOf(ch)!=-1)
c++
}
System.out.println(“Number of Vowels are”+c);
30

}
}

VARIABLE DESCRIPTION TABLE

S. VARIABLE DESCRIPTION DATATYPE


No
1 x Variable to input a String String
2 i Looping Variable Integer
3 l Variable to find the length of the Integer
inputed String
4 c Counting Variable Integer
5 ch Variable to extract characters from the char
inputed String
6 y String to check whether the inputed String
String consists of vowels or not
31

Ques 11) Write a program to input a string and convert the String into
Piglatin Form. (i.e. after converting the String into UpperCase place
the first vowel of the original word as the start of the new word along
with the remaining alphabets. The alphabets present before the vowel
being shifted towars the end followed by “AY”.)
class abc
{
public static void main(String x)
{
int i, l, p, s1, s2, s3;
char ch;
String y = “AEIOUaeiou”;
l = x.length();
x = x.toUpperCase();
for(i=o ; i<=l-1 ; i++)
{
ch = x.charAt(i);
32

if(y.indexOf(ch)! = -1)
{
p = i;
break;
}
}
s1= x.substring(0;p);
s2 = x.substring(p);
s3 = s2 + s1 + “AY”;
System.out.print(“Piglatin form of the inputed String is” + s3);
}
}
33

VARIABLE DESCRIPTION TABLE

S.No VARIABLE DESCRIPTION DATATYPE


1 x Variable to input a String String
2 i Looping Variable Integer
3 l Variable to find the length of the Integer
inputed String
4 p Variable to store the position of first Integer
vowel of the inputed String
5 ch Variable to extract character from the Char
inputed String
6 y Variable to enter a String a String String
consisting of vowels for checking
vowels from the inputed String
7 s1 Variable to add the extracted Integer
characters from the inputed String
8 s2 Variable to add the extracted Integer
characters from the inputed String
9 s3 Variable to add the extracted Integer
characters from the inputed String
and print the new Piglatin String
formed
34

Ques 12) Write a program to input a String and print only the
palindrome words of the String.
class palindrome
{
public static void main(String x)
{
int i, l;
char ch;
String y = “”, z = “”;
x = x+””;
l = x.length();
for(i=0 ; i<=l-1 ; i++)
{
ch = x.charAt(i);
if(ch!=’’)
{
y = y=ch;
z = ch+z;
}
else
{
y = y.trim();
z = z.trim();
35

if(y.equalsIgnoreCase(z))
System.out.println(“Palindrome words of the String are”+y);
y = “”;
z = “”;
}
}
}

VARIABLE DESCRIPTION TABLE

S. VARIABLE DESCRIPTION DATATYPE


No
1 x Variable for inputing the String String
2 i Looping Variable Integer
3 l Variable to find the length of the Integer
inputed String
4 ch Variable for extracting character from char
the inputed String
5 y Variable for inputing the extracted String
String from the original String
6 z Variable for inputing the extracted String
String from the original String
36

Ques 13) Write a program to accept a name and print the name in the
following manner.
INPUT:- Rajeev Kumar Singh
OUTPUT:- RKS
class string
{
public static void main(String x)
{
int i, l;
char ch;
String x = “”; y = “”;
x = x+””;
l = x.length();
for(i=0 ; i<=l-1 ; i++)
{
ch = x.charAt(i);
if(ch!=’’)
y = y+ch;
else
{
z = z+y.charAt(1);
y = “”;
37

}
System.out.println(“New string is”+z);
}
}

VARIABLE DESCRIPTION TABLE

S. VARIABLE DESCRIPTION DATATYPE


No
1 x Varible for inputing the String String
2 i Looping Variable Integer
3 l Variable for finding the length of the Integer
String
4 ch Variable for extracting characters from Char
the inputed String
5 y Variable for inputing the extracted String
String from the inputed String
6 z Variable to print the extracted String String
38

Ques 14) Write a program by considering the following statement to


change 26 to 15, January to August, Republic to Independence and
finally print the updated String. “January 26 is celebrated as the
Republic Day of India”.
class abc
{
public static void main()
{
int i, l;
char ch;
String x = “January 26 is celebrated as the Republic Day of India”;
String y = “”, z = “’;
x = x+””;
l = x.length();
for(i=0 ; i<=l-1 ; i++)
{
ch = x.charAt(i);
if(ch!=’’)
y = y+ch;
else
{
y = y.trim();
if(y.equalsIgnoreCase(“January”));
y = “August”;
39

else
if(y.equalsIgnoreCase(“Republic”));
y = “Independence”;
else
if(y.equals(“26”));
y = “15”;
z = z+y+””;
y = “”;
}
}
System.out.println(“The updated String is” + z);
}
}
40

VARIABLE DESCRIPTION TABLE

S. VARIABLE DESCRIPTION DATATYPE


No
1 i Looping Variable Integer
2 l Variable to find the length of the String Integer
3 ch Variable to extract characters char
4 x Variable to enter the String provided String
5 y Variable used to replace the String String
6 z Variable used to print the updated String
String
41

Primary
Programs
6 Programs including if else, pattern, series, and
general programs

Ques 15) Write a program to input a number and print whether it is a


prime number or not.
class prime
{
public static void main(int n)
{
42

int I, c=0;
for(i=1; i<=n; i++)
{
if(n%i==0)
c++;
}
if(c==2)
System.out.print(“Number is prime”);
else
System.out.print(“Number is not prime”);
}
}

VARIABLE DESCRIPTION TABLE

S. VARIABLE DESCRIPTION DATATYPE


No
1 n Variable to input number to check Integer
whether it is prime or not
2 i Looping Variable Integer
3 c Counting Variable Integer
43

Ques 16) Write a program to display the following pattern.


54321
5432
543
54
5
class pattern
{
Public static void main()
{
Int I, j;
For(i=1; i<=5; i++)
44

{
For(j=5; j>=1; j--)
{
System.out.print(j);
}
System.out.println();
}
}

VARIABLE DESCRIPTION TABLE

S. No VARIABLE DESCRIPTION DATATYPE


1 i Looping Integer
Variable
2 j Looping Integer
Variable
45

Ques 17) Write a program to print the following Fibonacci Series.


1, 2, 3, 5, 8, 13, _ _ _ _ _ _, 20 term
class fibonacci
{
public static void main()
{
int i, a=1, b=2, c;
System.out.print(a);
System.out.print(b);
for(i=1; i<=18: i++)
{
46

c = a+b;
System.out.print(c);
a=b;
b=c;
}
}
}

VARIABLE DESCRIPTION TABLE

S. VARIABLE DESCRIPTION DATATYPE


No
1 i Looping Variable Integer
2 a Variable for storing the first value of the Integer
series
3 b Variable for storing the second value of Integer
the series
4 c Variable for storing the sum of the two Integer
values and printing the succeeding
value of the series
47

Ques 18) Write a program to input any number and check whether the
number is automorphic or not. (Number should exist in the last of its
square).
Class atomorphic
{
Public static void main(int n)
{
Int r, sq=n*n, p, c=0, a;
While(n!=0)
{
R=n%10;
48

N=n/10;
C++;
}
P = (int)Math.pow(10,c);
A = sq%p;
If(a==x)
System.out.print(“Number is Automorphic”);
Else
System.out.print(“Number is not Automorphic”);
}
}
49

VARIABLE DESCRIPTION TABLE

S. VARIABLE DESCRIPTION DATATYPE


No
1 n Variable to input any number to check Integer
whether it is automorphic or not
2 sq Variable to store the square of the Integer
inputed number
3 p Variable to calculate the power of the Integer
counted numbers
4 c Counting Variable Integer
5 a Variable to store the number to check Integer
whether it is automorphic or not
6 r Variable for extracting the remainder Integer
from the inputed number
50

Ques 19) Write a program to enter any age and check whether it is of
a senior citizen or not.
class senior
{
public static void main(int age)
{
if(age>=60)
System.out.print(“Senior Citizen”);
else
System.out.print(“Not a Senior Citizen”);
}
}

VARIABLE DESCRIPTION TABLE

S. VARIABLE DESCRIPTION DATATYPE


No
1 int Variable to input age Integer
51

Ques 20) Write a program to input any number and check it is a triple
digit number or not.
Class triple
{
Public static void main(int n)
{
If(n>=100 && n<=999)
System.out.print(“Number is triple digit”);
Else
System.out.print(“Number is not triple digit”);
}
}

VARIABLE DESCRIPTION TABLE

S. VARIABLE DECRIPTION DATATYPE


No
1 int Variable to input any number Integer

You might also like