Kaveesha Holdiay Assignment
Kaveesha Holdiay Assignment
Sharjah
Department of science
CERTIFIED THAT THIS IS THE BONAFIDE RECORD OF
WORK
DONE IN PROJECT ACTIVITIES IN COMPUTER
APPLICATION
OF________________________________
REG NO.____________________________ GRADE 10 ___
DURING THE YEAR 2023 - 2024
TEACHER IN CHARGE
1._________________________________ ____________
INDEX
No. Program Pag
e
1. Program to check whether a number is ‘Neon’ or not 4
8. Write a program to store 10 numbers in SDA. Now display only those numbers 18
that are perfect square.
9. Program to search an element from an array using Linear search technique. 20
10. Program to search an element from an array using Binary search technique. 22
11. Program to accept a word and check whether the word is palindrome or not 24
12. Program to sort the states according to their names using Bubble sort 26
technique. (Descending order)
13 Write a Program to display piglatin form of word. 28
15. Write a program in Java to enter a string/sentence and display the length of 32
the longest word present in the string.
16. Write a program to input 10 names in an SDA. Arrange these names in 34
ascending order of letters, using selection sort technique.
17. .Write a class with the name Area using function overloading that compute the 36
area of following
(a)Area of circle =22/7*r*r
(b)Area of square=side*side
(c) Area of rectangle=length*breadth
18. Write a Program in Java to store the numbers in a 4*4 matrix in DDA. find the 38
sum of the numbers of each row and sum of the numbers of each column of
the matrix by using an input statement.
19. Write a Program in Java to store the numbers in a 4*4 matrix in DDA. find the 40
sum of the numbers of left diagonal and sum of the numbers of right diagonal
of the matrix by using an input statement.
20. Design a class to overload a function compare () as follows: 42
(i) void compare (int, int): to compare two integer values and print the greater
of the two integers.
(ii) void compare (char, char): to compare numeric value of two character and
1.Program to check whether a number is ‘Neon Number’ or not.
import java.util.*;
public class Neon
{
public static void main (String args[])
{
Scanner in = new Scanner (System.in);
int n,sum=0,p,d;
System.out.println("Enter the number: ");
n=in.nextInt();
p=n*n;
do
{
d=p%10;
sum=sum+d;
p=p/10;
}
while (p!=0);
if(sum==n)
System.out.println("Neon number.");
else
System.out.println("Not a Neon number.");
}
}
OUTPUT
Enter the number:
9
Neon number.
Enter the number:
12
Not a Neon number.
VARIABLE DESCRIPTION
SL Variables Data Type Description
no
.
1 n Int To Store the entered number
2 Sum Int To store the sum
3 p Int To store the number after squaring
import java.util.*;
public class Automorphic
{
public static void main (int num)
{
int p,f=0;
p=num*num;
do
{
if(num%10!=p%10)
{
f=1;
break;
}
else
{
num=num/10;
p=p/10;
}
}
while(num>0);
if(f==0)
System.out.println("Automorphic number");
else
System.out.println("Not an Automorphic number");
}
}
OUTPUT
Enter the number
25
Automorphic number
Enter the number
20
Not an Automorphic number
VARIABLE DESCRIPTION
SL Variables Data Type Description
no
.
1 `num` Int The input number to be checked if
it's an Automorphic number
2 p Int The square of the input number
(`num * num`).
3 f Int A flag variable used to indicate
whether the number is
Automorphic
OUTPUT
Enters the value 153 during execution:
The number 153 is an Armstrong Number
Enters the value 123 during execution:
The number 123 is not an Armstrong Number
VARIABLE DESCRIPTION
4.Program to print the sum of series S=1+(1+2)+(1+2+3)+…….. (1+2+3…..+n) (read the value
of n from the user)
import java.util.*;
public class Series
{
public static void main(String args[])
{
Scanner in = new Scanner (System.in);
long n,i,j;
System.out.println("Enter n");
n=in.nextLong();
long sum=0;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
sum=sum+j;
}
System.out.println("The sum of the series is "+sum);
}
}
OUTPUT
Enter n
5
The sum of the series is 35
Enter n
100
The sum of the series is 171700
VARIABLE DESCRIPTION
SL Variables Data Type Description
no
.
1 n long The input number that determines
the length of the series.
2 i long Loop control variable for the outer
loop, iterating from `1` to `n`.
3 j long Loop control variable for the inner
loop, iterating from `1` to `i`.
4 sum long Accumulates the sum of the series
5.Write a menu driven program to find the area of equilateral triangle, Isosceles triangle and a
scalene triangle as per user’s choice.
OUTPUT
Input:
1
Enter side of an Equilateral Triangle
6
Output:
Area=15.588457268119896
VARIABLE DESCRIPTION
Variable Data Description
Name Type
c int Stores the user's choice for the type of triangle.
s int Side length of the equilateral triangle.
a int Side length of the isosceles triangle.
b int Base length of the isosceles triangle.
m int First side length of the scalene triangle.
n int Second side length of the scalene triangle.
p int Third side length of the scalene triangle.
k double Semi-perimeter of the scalene triangle, calculated as (m + n +
p) / 2.0.
area double Area of the triangle based on the selected type.
6.Write a program in Java to store 15 numbers (even and odd numbers) in a single dimensional
Array (SDA). Calculate and display the sum of all even numbers and all odd numbers
separately.
import java.util.*;
public class Even_Odd
{
public static void main(String args[])
{
Scanner in = new Scanner (System.in);
int i,es=0,os=0;
int m[]=new int[15];
System.out.println("Enter the numbers in the cell");
for(i=0;i<15;i++)
{
m[i]=in.nextInt();
}
for(i=0;i<15;i++)
{
if(m[i]%2==0)
es=es+m[i];
else
os=os+m[i];
}
System.out.println("The sum of the even numbers "+es);
System.out.println("The sum of the odd numbers "+os);
}
}
OUTPUT
Input:
Enter the numbers in the cell 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Output:
The sum of the even numbers 56
The sum of the odd numbers 64
VARIABLE DESCRIPTION
import java.util.*;
public class SecondSmall{
public static void main(String args[]){
Scanner in = new Scanner(System.in);
int i,min,secondmin;
int a[] = new int[10];
for(i=0;i<10;i++){
System.out.println("Enter the value of Cell: "+(i+1));
a[i] = in.nextInt();
}
min= a[0];
for(i=0;i<10;i++){
if(a[i]<min)
min=a[i];
}
System.out.println("Smallest Number: "+min);
secondmin = a[9];
for(i=0;i<10;i++){
if(a[i]<secondmin && a[i]!=min)
secondmin = a[i];
}
System.out.println("Second Smallest Number: "+secondmin);
}
}
OUTPUT
Input:
Enter the value of Cell: 1
45
Enter the value of Cell: 2
23
Enter the value of Cell: 3
67
Enter the value of Cell: 4
12
Enter the value of Cell: 5
98
Enter the value of Cell: 6
34
Enter the value of Cell: 7
56
Enter the value of Cell: 8
12
Enter the value of Cell: 9
90
Enter the value of Cell: 10
29
Output:
Smallest Number: 12
Second Smallest Number: 23
VARIABLE DESCRIPTION
import java.util.*;
public class Perfect_sq
{
public static void main (String args[])
{
Scanner in=new Scanner(System.in);
int i,k=0;
int m[]=new int [10];
System.out.println("Enter the numbers in the cell");
for(i=0;i<10;i++)
{
m[i]=in.nextInt();
}
System.out.println("The numbers in perfect square are:");
for(i=0;i<10;i++)
{
k=(int)Math.sqrt(m[i]);
if(k*k==m[i])
{
System.out.println(m[i]);
}
}
}
}
OUTPUT
Input:
Enter the numbers in the cell
16 23 25 30 36 40 49 50 64 81
Output:
The numbers in perfect square are:
16
25
36
49
64
81
VARIABLE DESCRIPTION
import java.util.*;
public class LH_search
{
public static void main (String args[])
{
Scanner in = new Scanner (System.in);
int i, k = 0, ns;
int m[] = new int[10];
if(k == 1)
System.out.println("The number is present");
else
System.out.println("The number is not present");
}
}
OUTPUT
Input:
Enter the values in an Array
12 45 23 56 78 89 90 34 67 12
The number to be searched
56
Output:
The number is present.
VARIABLE DESCRIPTION
import java.util.*;
public class B_search
{
public static void main (String args[])
{
Scanner in = new Scanner(System.in);
int i,k=0,p=0,lb=0,ub=9,ns;
int m[]=new int[10];
System.out.print("Enter the value in Ascending order");
for(i=0;i<10;i++)
{
m[i]=in.nextInt();
}
System.out.println("Enter the number to be searched");
ns=in.nextInt();
while(lb<=ub)
{
p=(lb+ub)/2;
if(m[p]<ns)
lb=p+1;
if(m[p]>ns)
ub=p-1;
if(m[p]==ns)
{
k=1;
break;
}
}
if(k==1)
System.out.println("The number is present");
else
System.out.println("The number is not present");
}
}
OUTPUT
Input:
Enter the values in Ascending order:
10 20 30 40 50 60 70 80 90 100
Enter the number to be searched:
50
Output:
The number is present
VARIABLE DESCRIPTION
import java.util.*;
public class Palindrome
{
public static void main(String word)
{
int i,p;
String word1="";
char ch;
p=word.length();
for(i=p-1;i>=0;i--)
{
ch=word.charAt(i);
word1=word1+ch;
}
if(word1.equals(word))
System.out.println("Palindrome");
else
System.out.println("Not a Palindrome");
}
}
OUTPUT
Input:
Enter a word:
Radar
Output:
Palindrome
VARIABLE DESCRIPTION
import java.util.*;
public class Bubble_Sort
{
public static void main(String args[])
{
Scanner in = new Scanner (System.in);
String ch[]=new String [10];
String t="";
int i,j;
System.out.println("Enter the array elements");
for(i=0;i<10;i++)
ch[i]=in.next();
for(i=0;i<9;i++)
{
for(j=0;j<(9-i);j++)
{
if(ch[j].compareTo(ch[j+1])<0)
{
t=ch[j];
ch[j]=ch[j+1];
ch[j+1]=t;
}
}
}
System.out.println("The names in descending order are:");
for(i=0;i<10;i++)
System.out.println(ch[i]);
}
}
OUTPUT
Input:
Enter the array elements
apple
orange
banana
grape
kiwi
mango
pineapple
watermelon
pear
plum
Input:
The names in descending order are:
watermelon
pineapple
plum
pear
mango
kiwi
grape
banana
orange
apple
VARIABLE DESCRIPTION
VARIABLE DESCRIPTION
import java.util.*;
public class Chvowels
{
public static void main (String args[])
{
Scanner in = new Scanner (System.in);
int i,p;
String st,st1="";
char chr;
System.out.println("Enter the String");
st=in.next().toLowerCase();
p=st.length();
for(i=0;i<p;i++)
{
chr=st.charAt(i);
if(chr=='a'||chr=='e'||chr=='i'||chr=='o'||chr=='u')
st1=st1+(char)(chr+1);
else
st1=st1+chr;
}
System.out.println("The Interchanged word: "+st1);
}
}
OUTPUT
Enter the String
hello
The Interchanged word: hflmp
VARIABLE DESCRIPTION
import java.util.*;
public class Length
{
public static void main (String args[])
{
Scanner in = new Scanner (System.in);
System.out.println("Enter the sentence:");
String word=in.nextLine();
word+=" ";
int i,p;
String word1="",word2="";
char chr;
p=word.length();
for(i=0;i<p;i++)
{
chr=word.charAt(i);
if(chr ==' ')
{
if(word1.length()>word2.length())
word2=word1;
word1="";
}
else
{
word1+=chr;
}
}
System.out.println("The longest word : "+word2);
System.out.println("The length of the longest word is: "+word2.length());
}
}
OUTPUT
Input:
Enter the sentence:
The quick brown fox jumps over the lazy dog
Output:
The longest word : jumps
The length of the longest word is: 5
VARIABLE DESCRIPTION
import java.util.*;
public class Sel_sort
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int i,j,t,min;
int m[] = new int[10];
System.out.println("Enter the numbers in the cell");
for(i=0;i<10;i++)
{
m[i] = in.nextInt();
}
for(i=0;i<9;i++)
{
min=i;
for(j=i+1;j<10;j++)
{
if (m[j]<m[min])
min=j;
}
t= m[i];
m[i] = m[min];
m[min]=t;
}
System.out.println("The numbers arranged in ascending order are:");
for(i=0;i<10;i++)
System.out.println(m[i]);
}
}
OUTPUT
Input:
Enter the numbers in the cell
64
25
12
22
11
90
88
56
35
75
Output:
The numbers arranged in ascending order are:
11
12
22
25
35
56
64
75
88
90
VARIABLE DESCRIPTION
import java.util.*;
public class Compute
{
double area(double r)
{
double ar1=22/7*r*r;
return(ar1);
}
int area (int sd)
{
int ar2=sd*sd;
return(ar2);
}
int area(int l,int b)
{
int ar3=l*b;
return(ar3);
}
public static void main(String args[])
{
Scanner in = new Scanner (System.in);
int s=0,a=0,br=0;
double ri=0.0;
System.out.println("Enter the radius of a circle: ");
ri=in.nextDouble();
System.out.println("Enter the side of a square: ");
s=in.nextInt();
System.out.println("Enter the length and breadth of a rectangle: ");
a=in.nextInt();
br=in.nextInt();
Compute ob=new Compute();
double m=ob.area(ri);
int n=ob.area(s);
int p=ob.area(a,br);
System.out.println("The area of a Circle: "+m);
System.out.println("The area of a Square: "+n);
System.out.println("The area of a Rectangle : "+p);
}
}
OUTPUT
Enter the radius of a circle:
7
Enter the side of a square:
4
Enter the length and breadth of a rectangle:
56
The area of a Circle: 154.0
The area of a Square: 16
The area of a Rectangle : 30
VARIABLE DESCRIPTION
import java.util.*;
public class RC_sum
{
public static void main (String args[])
{
Scanner in = new Scanner (System.in);
int i,j,r,c;
int m[][]=new int[4][4];
System.out.println("Enter the numbers in the array");
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
m[i][j]=in.nextInt();
}
System.out.println("The numbers of the matrix are");
for(i=0;i<4;i++)
{
for(j=0;j<4;i++)
{
System.out.print(m[i][j]+" ");
}
System.out.println();
}
System.out.println("The sum of the elements of each row");
for(i=0;i<4;i++)
{
r=0;
for(j=0;j<4;j++)
{
r=r+m[i][j];
}
System.out.println("Sum of"+i+1+"row ="+r);
}
System.out.println("The sum of the elements of each coloumn");
for(i=0;i<4;i++)
{
c=0;
for(j=0;j<4;j++)
{
c=c+m[j][i];
}
System.out.println("Sum of "+i+1+"column ="+c);
}
}
}
OUTPUT
Enter the number:
9
Neon number.
Enter the number:
12
Not a Neon number.
VARIABLE DESCRIPTION
import java.util.*;
public class SDiagonals
{
public static void main (String args[])
{
Scanner in = new Scanner (System.in);
int i,j,ld=0,rd=0;
int m[][] = new int[4][4];
System.out.println("Enter the numbers in the array");
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
m[i][j]=in.nextInt();
}
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
if(i==j)
ld=ld+m[i][j];
if(i+j==3)
rd=rd+m[i][j];
}
}
System.out.println("The sum of the left diagonal = "+ld);
System.out.println("The sum of the right diagonal ="+rd);
}
}
OUTPUT
Enter the numbers in the array:
1234
5678
9 10 11 12
13 14 15 16
VARIABLE DESCRIPTION
import java.util.*;
public class Compare
{
public void compare(int a, int b)
{
if(a>b)
System.out.println("the bigger number is"+a);
else
System.out.println("the bigger number is"+b);
}
public void compare (char x,char y)
{
int i=(int)x;
int j=(int)y;
if(i>j)
System.out.println("The larger character is"+i);
else
System.out.println("The larger character is"+j);
}
public void compare(String m,String n)
{
int k=m.length();
int l=n.length();
if(k>l)
System.out.println("The larger string is"+m);
else
System.out.println("The larger string is"+n);
}
public static void main (String args[])
{
Scanner in = new Scanner (System.in);
int a1=0,b1=0;
char x1,y1;
String m1="",n1="";
System.out.println("Enter the digits ");
a1=in.nextInt();
b1=in.nextInt();
System.out.println("Enter the Characters ");
x1=in.next().charAt(0);
y1=in.next().charAt(0);
System.out.println("Enter the Strings ");
m1=in.next();
n1=in.next();
Compare ob=new Compare();
ob.compare(a1,b1);
ob.compare(x1,y1);
ob.compare(m1,n1);
}
}
OUTPUT
Enter the digits
7 12
Enter the Characters
az
Enter the Strings
apple orange
VARIABLE DESCRIPTION