Computer Practical File 2025-26
Computer Practical File 2025-26
COMPUTER
PRACTICAL FILE
SUBMITTED TO: SUBMITTED BY:
Mr. Vijay Baretha
Class :
Roll No:
________________ ______________
External Examiner 1 Internal Examiner
ACKNOWLEDGEMENT
I would like to thank my Computer Application teacher
[Link] Baretha for his able guidance and support in
completing my project. I would also like to extend my
gratitude to the Principal Rev. Fr. Gerald D‟Souza for
providing me with all the facility that was required.
Date:
Name: ________________
Class:______________
2
INDEX
[Link]. Question Page Remarks
no.
WAP to input the names of 5 cities in an array
1 6
and search for names of the cities in an array
using linear search.
3
[Link]. Question Page Remarks
no.
4
[Link]. Question Page Remarks
no.
5
PROGRAM-1
WAP to input the names of 5 cities in an array and search for names
of the cities in an array using linear search.
import [Link].*;
class city
{
public static void main(String args[])
{
String a[ ]=new String [5];
int f=0,i,x;
Scanner sc= new Scanner([Link]);
[Link]("Enter the names of 5 cities");
for(i=0;i<5;i++)
{
a[i]=[Link]();
}
[Link]("Enter the city name to be search");
String s=[Link]();
for(x=0;x<=4;x++)
{
if(a[x].equals(s))
{
f=1;
break;
}
}
if(f==1)
[Link]("City name found at position="+(x+1));
else
[Link]("no such city name is found");
}
}
6
Output:
7
PROGRAM-2
import [Link].*;
class binary_search
{
public static void main( )
{
int a[ ]=new int[5];
int f=0,i,s,l,u,mid;
Scanner sc= new Scanner([Link]);
[Link]("Enter the vlaues in ascending order");
for(i=0;i<5;i++)
{
a[i]=[Link]();
}
[Link]("Enter the elementto be search");
s=[Link]();
l=0;
u=4;
while(l<=u)
{
mid=(l+u)/2;
if(a[mid]==s)
{
f=1;
[Link]("Element found at position="+(mid+1));
break;
}
else if(a[mid]<s)
l=mid+1;
else if(a[mid]>s)
u=mid-1;
8
}
if(l>u)
[Link]("No such Element name is found");
}
}
Output :
9
PROGRAM-3
class nested_loop
{
public static void main()
{
int i,j,a=1;
for(i=1;i<=5;i++ )
{
for(j=1;j<=i;j++)
{
[Link](a+" ");
a++;
}
[Link]( );
}
}
}
10
Output:
11
PROGRAM-4
12
Output:
13
PROGRAM-5
WAP to input the age, gender (and Taxable Income of person male
or female) and Taxable Income of a [Link] the age more than 65
years or the gender is female, display “wrong category”. If the age is
less than or equal to 65 years and the gender is male<compute and
display the income Tax payable as per the table give below:
import [Link].*;
class Tax
{
public static void main()
{
Scanner sc= new Scanner([Link]);
double IT=0,TI;
int age;
char gender;
[Link]("Enter age ");
age=[Link]();
[Link]("Enter gender as m or f");
gender=[Link]().charAt(0);
[Link]("Enter total income of the person");
TI=[Link]();
if(age<=65 && gender=='m')
{
if(TI<=160000)
IT=0;
else if(TI>160000 && TI<=500000)
14
IT=(TI-160000)*0.1;
else if(TI>500000 && TI<=800000)
IT=((TI-500000)*0.2)+34000;
else if(TI>800000)
IT=((TI-800000)*0.3)+94000;
[Link]("INCOME TAX="+IT);
}
else
[Link]("Wrong category");
}
}
Output :
15
PROGRAM-6
WAP to input three number and print them in ascending order
(using else-if ladder)
import [Link].*;
class abc
{
public static void main()
{ Scanner sc= new Scanner([Link]);
int a,b,c;
[Link]("Enter the three values");
a=[Link]();
b=[Link]();
c=[Link]();
if(a>b && a>c)
{ if(b>c)
[Link](c+","+b+","+a);
else
[Link](a+","+c+","+a);
}
else if(b>a && b>c)
{
if(a>c)
[Link](c+","+a+","+b);
else
[Link](a+","+c+","+b);
}
else if(c>a && c>b)
{
if(a>b)
[Link](b+","+a+","+c);
else
[Link](a+","+b+","+c);
}
}
}
16
Output:
17
PROGRAM-7
import [Link].*;
public class duck_number
{
public static void main(String args[])
{
Scanner sc=new Scanner([Link]);
int r,c=0,n;
[Link]("Enter your number to be checked.");
n=[Link]();
while(n!=0)
{
r=n%10;
n=n/10;
if(r==0)
c++;
}
if(c>0)
[Link]("It is a duck number.");
else
[Link]("It is not a duck number.");
}
}
18
Output:
19
PROGRAM-8
WAP to take a number from the user and check and print weather
the given number is Spy number or Not.
import [Link].*;
class spy_num
{
public static void main( )
{
Scanner sc= new Scanner([Link]);
int r,S=0,p=1,n;
[Link]("Enter the value");
n=[Link]();
while(n!=0)
{
r=n%10;
n=n/10;
S=S+r;
p=p*r;
}
if(S==p)
[Link]("Spy Number.");
else
[Link]("Not a Spy Number.");
}
}
20
Output:
21
PROGARM-9
WAP to input a number and print whether it is a HAPPY numberor not.
import [Link].*;
class Happy
{
public static void main(String args[])
{
int num;
Scanner sc=new Scanner([Link]);
[Link]("Enter a positive integer");
num=[Link]();
int dig,sum=0,m=num;
while(num>9)
{
while(num>0)
{
dig=num%10;
sum=sum+(dig*dig);
num=num/10;
}
num=sum;
sum=0;
}
if(num==1)
{
[Link](m+"is a HAPPY number");
}
else
{
22
[Link](m+"is not a HAPPY number");
}}}
Output :
23
PROGRAM-10
24
Output :
25
PROGRAM-11
import [Link].*;
class abc
{
public static void main()
{
Scanner sc = new Scanner([Link]);
int i,l;
char ch;
String s,s2="";
[Link]("Enter the string");
s=[Link]();
l= [Link]();
for(i=0;i<=l-1;i++)
{
ch=[Link](i);
if([Link](ch)==-1)
s2=s2+ch;
}
[Link](s2);
}
}
26
Output:
27
PROGRAM-12
import [Link].*;
class series
{
public static void main( )
{
Scanner sc= new Scanner([Link]);
int i,d,s=0,f=1,x,n;
[Link]("enter the value of the x and N");
x=[Link]();
n=[Link]();
for(i=1;i<=n;i++)
{
f=f*i;
d=(int) [Link](x,i)/f;
s=s+d;
}
[Link]("The sum of the series is="+s);
}
}
28
Output:
29
PROGRAM-13
import [Link].*;
class abc
{
public static void main()
{
Scanner sc= new Scanner([Link]);
int i,a=1,b=4,c=5,d,n;
[Link]("Enter the limit");
n=[Link]();
[Link](a+","+b+","+c);
for(i=1;i<=n-3;i++)
{
d=a+b+c;
[Link](","+d);
a=b;
b=c;
c=d;
}
}
}
30
Output :
31
PROGRAM-14
import [Link].*;
class funcDak
{
public int alter(int a)
{
int b=a*2-3;
return b;
}
public String alter(String s)
{
int len=[Link]();
String n="";
for(int x=0;x<len;x++)
{
char c=[Link](x);
n=c+n;
}
return n;
}
32
public char alter(char c)
{
char m=(char)(c+1);
return m;
}
public static void main()
{
funcDak ob= new funcDak();
int x=[Link](7);
[Link]("The result of the first function is="+x);
String s=[Link]("apple");
[Link]("The result of the second function is="+s);
}
}
33
Output:
34
PROGRAM-15
import [Link].*;
class while_loop_12
{
public static void main()
{
int r,c,i,m,n;
Scanner sc= new Scanner([Link]);
[Link]("Enter the number");
n=[Link]();
[Link]("Digit\tFrequency");
for(i=0;i<=9;i++)
{
m=n;c=0;
while(m!=0)
{
r=m%10;
m=m/10;
if(r==i)
c++;
}
if(c>0)
[Link](i+"\t"+c);
}
}
}
35
Output :
36
PROGRAM-16
38
Output :
39
PROGRAM-17
import [Link].*;
class Prime_palindrom
{
public boolean is_prime (int x)
{
int i, c=0;
for(i=1;i<=x;i++)
{
if(x%i==0)
c++;
}
if(c==2)
return true;
else
return false;
}
public boolean is_palin(int x)
{
int s=0,r,m=x;
while(x!=0)
40
{
r=x%10;
x=x/10;
s=10*s+r;
}
if(s==m)
return true;
else
return false;
}
public void show(int n1, int n2 )
{
int i;
boolean Z, K;
for(i=n1;i<=n2;i++)
{
Z=is_prime(i);
K=is_palin(i);
if(Z==true && K==true)
[Link](i+",");
}
}
public static void main ()
{
Scanner sc= new Scanner([Link]);
Prime_palindrom ob =new Prime_palindrom( );
int a,b;
[Link]("enter the lower limit");
a=[Link]();
[Link]("enter the upper limit");
b=[Link]();
[Link](a,b);
}
}
41
Output:
import [Link].*;
class function_2
{
public int fact(int a)
{
int i,f=1;
for(i=1;i<=a;i++)
{
f=f*i;
}
return f;
}
public static void main( )
{
Scanner sc= new Scanner([Link]);
int x,y,z,n,m;
double s;
function_2 ob= new function_2();
[Link]("enter the value of n and m");
n=[Link]();
m=[Link]();
x=[Link](n);
y=[Link](m);
z=[Link](n-m);
s=1.0*x/(y*z);
[Link]("the value is ="+s);
}
}
43
Output:
44
PROGRAM-19
45
Output:
46
PROGRAM-20
47
Output :
48
PROGRAM-21
WAP to input a matrix of size 4x4 and print the sum of boundary
elements.
import [Link].*;
class matrix_1
{
public static void main()
{
int i,j,s=0;
int a[][]=new int[4][4];
Scanner sc= new Scanner([Link]);
[Link]("enter the matrix ");
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
{
a[i][j]=[Link]();
}
}
[Link]("The original matrix is: ");
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
{
[Link](a[i][j]+" ");
}
[Link]();
}
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
{
if(i==0 || i==3 || j==0 || j==3)
s=s+a[i][j];
}
49
}
[Link]("the sum of boundary elements="+s);
}
}
Output :
WAP to input a matrix of size 4x4 and print the sum of diagonals
elements of the matrix.
import [Link].*;
class matrix_3
{
public static void main()
{
int i,j,s=0,s1=0;
int a[][]=new int[4][4];
Scanner sc= new Scanner([Link]);
[Link]("enter the matrix ");
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
{
a[i][j]=[Link]();
}
}
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
{
if(i==j)
s=s+a[i][j];
else if(i+j==3)
s1=s1+a[i][j];
}
}
[Link]("\nthe matrix elements is");
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
{
51
[Link](a[i][j]+" ");
}
[Link]();
}
Output :
52
Variable description table
53
PROGRAM-23
WAP to input a matrix of size 4x4 and print the transpose of the
matrix.
import [Link].*;
class matrix_6
{
public static void main()
{
int i,j;
int a[][]=new int[4][4];
int b[][]=new int[4][4];
Scanner sc= new Scanner([Link]);
[Link]("enter the matrix ");
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
{
a[i][j]=[Link]();
}
}
[Link]("\nThe original matrix elements is");
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
{
[Link](a[i][j]+" ");
}
[Link]();
}
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
{
b[j][i]=a[i][j];
}
54
}
[Link]("\nthe transopse matrix elements is");
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
{
[Link](b[i][j]+" ");
}
[Link]();
}
}
}
Output :
55
Variable description table
56
PROGRAM-24
import [Link].*;
class selection_sort
{
public static void main()
{
Scanner sc= new Scanner([Link]);
int a[]= new int[10];
int i,p,min,j,t;
[Link]("enter the array element");
for(i=0;i<=9;i++)
{
a[i]=[Link]();
}
[Link]("\nThe original array is:");
for(i=0;i<=9;i++)
{
[Link](a[i]+",");
}
for(i=0;i<=9;i++)
{
p=i;
min=a[i];
for(j=i+1;j<=9;j++)
{
if(a[j]<min)
{
min=a[j];
p=j;
}
}
t=a[i];
a[i]=a[p];
57
a[p]=t;
}
[Link]("\nThe sorted array is:");
for(i=0;i<=9;i++)
{
[Link](a[i]+",");
}
}
}
Output :
58
Variable description table
59
PROGRAM-25
WAP to input an int array of size 10 and sort then in descending order
by using bubble sort.
import [Link].*;
class bubble_sort
{
public static void main()
{
Scanner sc= new Scanner([Link]);
int a[]= new int[10];
int i,p,min,j,t;
[Link]("enter the array element");
for(i=0;i<=9;i++)
{
a[i]=[Link]();
}
[Link]("\nThe original array is:");
for(i=0;i<=9;i++)
{
[Link](a[i]+",");
}
for(i=0;i<=9;i++)
{
for(j=0;j<=8-i;j++)
{
if(a[j]<a[j+1])
{ t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
[Link]("\nThe sorted array is:");
60
for(i=0;i<=9;i++)
{
[Link](a[i]+",");
}
}
}
Output :
61
Variable description table
62