0% found this document useful (0 votes)
5 views12 pages

Class 11 Computer Project

Uploaded by

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

Class 11 Computer Project

Uploaded by

pnavyahraj31
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

DON BOSCO SCHOOL, SILIGURI – 734001

PROJECT
COMPUTER SCIENCE
CLASS – XI
2025-26
Following points need to be considered:
 Write the question.
 Write the program coding.
 Take screenshots of output.
 Variable description.
 [Note: Except the printout for output screenshot, rest of the things must be
handwritten]
1. Solve the following pattern:-

7654321
*54321
**321
***1
**321
*54321
7654321

class pattern
{
void main()
{
int i,j,k,c=0,f=0;
for(i=7;i>0;i=i-2)
{
for(k=0;k<c;k++)
[Link]('*');
c=c+1;
for(j=i;j>0;j--)
{
[Link](j);
}
[Link]();
}
c=2;
for(i=3;i<7;i=i+2)
{
for(k=0;k<c;k++)
[Link]('*');
c=c-1;
for(j=i;j>0;j--)
{
[Link](j);
}
[Link]();
}
}
}

2. Write a program to fill a 2-D array of size 4*4 column-wise with the first 16 Magic numbers.
Print the 2-D array after filling is done.
[Logic: If eventual (repeated) sum of the digits of a number is equal to 1, then the number is
considered as Magic number.
Example: 874=8+7+4=19=1+9=10=1+0=1
28=2+8=10=1+0=1
Etc.]

import [Link].*;
class Magic
{
boolean ismagic (int x)
{
int m,d,s=0;
m=x;
while(m>9)
{
while(m>0)
{
d=m%10;
m=m/10;
s=s+d;
}
m=s; s=0;
}
if(m==1)
return true;
else
return false;
}

void main()
{
int a[][]=new int[4][4],k=1;
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
if(ismagic(k)==true)
a[j][i]=k;
else
j--;
k=k+1;
}
}
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
[Link](a[i][j]+" ");
}
[Link]();
}
}
}
3. Write a program to enter a 2-D array of size 5*5. Find and print the largest Bouncy number
considering each column if present else print an appropriate message.

[A number is said to Bouncy number if the digits of the number are unsorted.
For example,
22344 - It is not a Bouncy number because the digits are sorted in ascending order.
774410 - It is not a Bouncy number because the digits are sorted in descending order.
155349 - It is a Bouncy number because the digits are unsorted.
A number below 100 can never be a Bouncy number.]

import [Link].*;
class Bouncy
{
void main()
{
int a[][]=new int[5][5],i,j,m,d,c=0,r=0,g=0,l=0,x=0;
Scanner sc=new Scanner([Link]);
[Link]("enter your numbers:");
for(i=0;i<5;i++)
for(j=0;j<5;j++)
{
a[i][j]=[Link]();
if(a[i][j]<100)
j--;
}
for(i=0;i<5;i++)
{
l=0;
for(j=0;j<5;j++)
{
for(int k=9;k>=0;k--)
{
m=a[j][i];
while(m>0)
{
d=m%10;
m=m/10;
if(d==i)
{
r=r*10+d; g=g+(int)[Link](10,c++)*d;
}
}
}
if(r!=a[j][j] && g!=a[j][i])
{
if(l==0 || a[j][i]>l)
l=a[j][i];
}
}
[Link]("Largest Bouncy for"+(x++)+"column:"+l);
}
}
}
4. Write a program to declare a matrix A[][] of order (m*n) where m is the number of rows and n
is the number of columns such that both m and n must be greater than 2 and less than 20. Allow
the user to input positive integers into the matrix. Perform the following tasks:
a) Sort the elements of the outer row and column in ascending order using any standard sorting
technique.
b) Calculate the sum of the outer row and column elements.
c) Output the original matrix, rearranged matrix and only the boundary elements of the
rearranged matrix with their sum.
Sample Input: m=3 and n=3
1(0,0) 7(0,1) 4(0,2)
8(1,0) 2(1,1) 5(1,2)
6(2,0) 3(2,1) 9(2,2)

Output: 1 3 4 5 6 7 8 9
Original Matrix:
1 7 4
8 2 5
6 3 9
Rearranged Matrix:
1 3 4
9 2 5
8 7 6
Boundary Elements:
1 3 4
9 5
8 7 6
Sum of the outer row and column elements = 43

import [Link].*;
class Question4
{
void main()
{
Scanner sc=new Scanner([Link]);
int m,n,i,j,c=0,p,t,s=0;
[Link]("Enter the values of 'm' and 'n' where values of BOTH are greater
than 2 and less than 20:");
m=[Link](); n=[Link]();
if(m<2||m>20 && n<2||n>20)
{
m=0; n=0;
[Link]("Wrong choice, enter again for 'm' and 'n' again:");
m=[Link](); n=[Link]();
}
int A[][]=new int[m][n],b[]=new int[m*n];
[Link]("Enter the array with ONLY positive integers:");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
{
A[i][j]=[Link]();
if(A[i][j]<0)
{
[Link]("Invalid Integer, Enter Again:");
j--;
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(i==0||j==0||i==(m-1)||j==(n-1))
{
b[c++]=A[i][j];
s=s+A[i][j];
}
}
}
for(i=0;i<c-1;i++)
{
p=i;
for(j=i+1;j<c;j++)
{
if(b[j]<b[p])
p=j;
}
t=b[i];
b[i]=b[p];
b[p]=t;
}
for(j=0;j<c;j++)
[Link](b[j]+" ");
[Link]("Original Matrix:");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
[Link](A[i][j]+" ");
[Link]();
}
t=0;
for(i=0;i<n;i++)
A[0][i]=b[t++];
for(i=1;i<m;i++)
A[i][n-1]=b[t++];
for(i=n-2;i>=0;i--)
A[m-1][i]=b[t++];
for(i=m-2;i>0;i--)
A[i][0]=b[t++];
[Link]("Rearranged Matrix:");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
[Link](A[i][j]+" ");
[Link]();
}
[Link]("Boundary Elements:");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(i==0||j==0||i==(m-1)||j==(n-1))
{
[Link](A[i][j]+" ");
}
else
[Link](" ");
}
[Link]();
}
[Link]("Sum of outer row and column elements:"+s);
}
}

5.

import [Link].*;
class Exchange
{
String sent, newStr;
int size;
Exchange()
{
sent=""; newStr="";
size=0;
}

void readsentence()
{
Scanner sc=new Scanner([Link]);
[Link]("Enter the sentence terminated by a full stop:");
sent=[Link]();
}

void NewWord()
{
size=[Link]();
for(int i=0;i<size;i++)
{
char ch=[Link](i);
if([Link](ch)==true)
{
if("AEIOUaeiou".indexOf(ch)>0)
newStr=newStr+ch;
else
newStr=ch+newStr;
}
}
newStr=newStr+'.';
}

void display()
{
[Link]("Original sentence:"+sent);
[Link]("New Sentence:"+newStr);
}

static void main()


{
Exchange obj=new Exchange();
[Link]();
[Link]();
[Link]();
}
}

6. A class saddle_point is declared with the following details:

Class name : saddle_point


Data members/instance
variables :
x[ ][ ] : a double dimensional array of integers of maximum size 8 X 8.
m, n : integers to store the number of rows and number of columns.
Member methods :
saddle_point( ) : constructor to initialize the data members.
saddle_point(int p, int q) : parameterized constructor to initialize m = p and n = q.
void accept( ) : to input integers in the matrix x[ ][ ] of m rows, n columns.
void show( ) : to print the matrix x[ ][ ] row wise.
void display( ) : to find and print the saddle point from the matrix x[ ][ ]. A saddle
point from any matrix is determined by finding smallest element
in a row, which should be greatest in its corresponding column.
Example:
Input: m = 3, n = 4
Input matrix:
3 5 7 4
1 6 4 9
2 4 7 5

Output matrix:
3 5 7 4
1 6 4 9
2 4 7 5

Saddle point = 3 present at Row = 1 and column = 1

import [Link].*;
class saddle_point
{
int x[][],n,m;
saddle_point()
{
x=new int[8][8];
m=0; n=0;
}

saddle_point(int p,int q)
{
m=p; n=q;
x=new int[m][n];
}

void accept()
{
Scanner sc=new Scanner([Link]);
[Link]("Enter the numbers into the array:");
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
x[i][j]=[Link]();
}

void show()
{
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
[Link](x[i][j]+" ");
[Link]();
}
}

void display()
{
int s=0,l=0,p=0,q=0;
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
if(s==0||x[i][j]<s)
{
s=x[i][j]; p=j;
}
}
for(int j=0;j<m;j++)
{
if(l==0||x[j][p]>l)
{
l=x[j][p]; q=j;
}
}
if(s==l)
[Link]("Saddle Point="+(s)+" present at row="+(p+1)+" and
column="+(q+1));
l=0; s=0;
}
}

void main()
{
saddle_point obj=new saddle_point(3,4);
[Link]();
[Link]();
[Link]();
}
}

7. Write a program to enter a sentence that must terminate with either ‘?’ or ‘!’ or ‘.’ but not with
any other character. If the sentence is valid, then form a new sentence by considering only the
words, which are having double letter sequence in them.
Sample Input:
AMAN WAS FEEDING A LITTLE RABBIT WITH AN APPLE!
Sample Output:
FEEDING LITTLE RABBIT APPLE

import [Link].*;
class Question7
{
void main()
{
Scanner sc=new Scanner([Link]);
String s,w="";
int x=0;
[Link]("enter the sentence:");
s=[Link]();
if(!([Link]("?")||[Link]("!")||[Link](".")))
{
[Link]("Invalid");
[Link](0);
}
else
{
s=s+" ";
for(int i=0;i<[Link]();i++)
{
char ch=[Link](i);
if(ch!=' ')
w=w+ch;
else
{
if ([Link](".") || [Link]("!") || [Link]("?"))
w=[Link](0,[Link]()-1);
if([Link]()>2)
{
for(int j=0;j<[Link]()-1;j++)
if([Link](j)==[Link](j+1))
{
x=1; break;
}
if(x==1)
[Link](w+" ");
}
w=""; x=0;
}

}
}
}
}

8. Write a program to input a number and check whether it is a Fascinating number or not.
Fascinating Numbers: Some numbers of 3 digits or more exhibit a very interesting property.
The property is such that, when the number is multiplied by 2 and 3, and both these products are
concatenated with the original number, all digits from 1 to 9 are present exactly once, regardless
of the number of zeroes.
Lets understand the concept of Fascinating number through the following example:
Consider the number 192,
192X1 = 192
192X2 = 384
192X3 = 576
Concatenating the results: 192384576
It could be observed that ‘192384576’ consists of all digits from 1 to 9 exactly once. Hence, it
could be concluded that 192 is a Fascinating number.
Some examples of Fascinating numbers are:
192, 219, 273, 327, 1902, 1920, 2019 etc.

import [Link].*;
class Fascinating
{
int count(int n)
{
int m,d,c=0;
m=n;
while(m>0)
{
d=m%10;
m=m/10;
c++;
}
return c;
}

void main(int n)
{
[Link]("Number entered:"+n);
int n2,n3,m,d,x,f=0,y=0,a=0;
String cn,cn2,cn3,c;
if(count(n)>2)
{
n2=n*2; n3=n*3;
cn=[Link](n);
cn2=[Link](n2);
cn3=[Link](n3);
c=cn+cn2+cn3;
if([Link]()>=9)
{
for(int j=1;j<=9;j++)
{
for (int k=0;k<[Link]();k++)
{
int digit=[Link](k)-'0';
if (digit==j)
{
a=1;
break;
}
}
if (a==1)
y++;
a=0;
}
if (y==9)
[Link]("It is a Fascinating number.");
else
[Link]("It is NOT a Fascinating number.");
}
else
{
x=[Link](c);
for(int i=1;i<=9;i++)
{
m=x;
while(m>0)
{
d=m%10;
m=m/10;
if(d==i) {
f=1; break; }
}
if(f==1)
y++;
f=0;
}
if(y==9)
[Link]("It is a Fascinating number.");
else
[Link]("It is NOT a Fascinating number.");
}
}
}
}

You might also like