11 Project Computer 2024
11 Project Computer 2024
Class -XI
COMPUTER SCIENCE
ASSIGNMENT (2024 – 25)
_ _
1. Write a program in Java to accept a decimal number and convert it equivalent binary, octal
(without using String & array) & hexadecimal form. Test your program forthe following data & some
random data.
(Use minimum complexity to convert the base value & don’t use any inbuilt methods)Class Name:
Number_System
Instance Method:
void binary (int dec) : to convert the decimal number to binaryvoid octal
(int dec) : to convert the decimal number to octal
void hexa (int dec) : to convert the decimal number to hexa-decimal
2. Write a program in Java to display all the composite Fibonacci number between 1to ‘n’ (both
inclusive).
Composite Fibonacci No = 8, 34, 55 [The number that is a non-prime number &also a
Fibonacci Number]
Instance Method:
boolean check_Composite (int n) : to check the ‘n’ is Prime or not, using bestmethod & if it is
int chk_Fibo (int n) : to check the ‘n’ is Fibonacci or not (withoutusing 3rd
Write a main ( ) to test your class & call the methods using object.
3. Write a program in Java do the following task:
Create a main() method to input a number and enable the above task.
4. Write a program which will accept N words in Uppercase and display the frequency of the characters of each
word as per sequence they are present in the word.
Example:
Word: APPLICATION
Frequency of A: 2
Frequency of P: 2
Frequency of L: 1
Frequency of I: 2
Frequency of C: 1
Frequency of T: 1
Frequency of O: 1
Frequency of N: 1
5. Write a Java program to display all the amicable pairs between lower and upper range given by the user.
Amicable numbers are two different numbers so related that the sum of the proper divisors of each is equal to the
other number. Give appropriate message if no such pairs exists within the range. Also display the frequency of the
amicable pairs.
The first ten amicable pairs are: (220, 284), (1184, 1210), (2620, 2924), (5020, 5564), (6232, 6368), (10744, 10856),
(12285, 14595), (17296, 18416), (63020, 76084), and (66928, 66992).
and so on altering right and left until all the integers are done.
7 3 1 6 4 2 5 7 3 1 6 4 2
After re-arrangement the array becomes
then after rearranging it becomes
7 5 3 1 2 4 6 6 3 1 2 4 7
7. Write a program to declare a matrix A[][] having order MxN( where M is no. of rows and N is no. of columns)
where values of both M and N must be greater than 2 and less than 10.Allow the user to accept value for matrix.
Perform the following tasks:
a) Display original matrix
b) Sort each odd row of the matrix in ascending order and each even row of the matrix in descending order
using any sorting algorithm.
c) Display the final updated matrix.
8. A Composite Magic number is a positive integer which is composite as well as a magic number. Composite
number: A composite number is a number that has more than two factors. Example: 10 Factors are: 1, 2, 5, 10
Magic number: A magic number is a number in which the eventual sum of the digits is equal to 1.
Example: 28 = 2+8 = 10 = 1+0 = 1 Accept two positive integers m and n, where m is less than n as user
input. Display the number of Composite Magic integers that are in the range between m and n (both inclusive)
and output them along with the frequency, in the format specified below:
Test your program for the following data and some random data.
Example 1
INPUT: m = 40 n = 100
OUTPUT:
THE COMPOSITE MAGIC INTEGERS ARE: 46, 55, 64, 82, 91, 100
FREQUENCY OF COMPOSITE MAGIC INTEGERS IS: 6
void check(): checks whether the given number is Composite Magic number by invoking the functions
and displays the result with an appropriate message
Define a main() function to create an object and call the functions accordingly to enable the task.
9. 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 than10. Allow the user to
input integers into this matrix. Display appropriate error message for an invalid input. Perform the
following tasks on the matrix.
(a) Display the input matrix
(b) Rotate the matrix by 2700 degrees anti clock wise and display the resultant matrix (c) Calculate
the sum of the odd elements of the matrix and display
Test your program for the following data and some random data:
Example 1
INPUT: M = 3 N = 4
ENTER ELEMENTS: 8, 7, 9, 3,-2, 0, 4, 5, 1, 3, 6, -4
OUTPUT:
ORIGINALMATRIX
8793
-2 0 4 5
1 3 6 -4
ROTATED MATRIX ( 2700 ANTI CLOCK WISE )
1 -2 8 3
0764
9 -4 5 3
SUM OF THE ODD ELEMENTS = 28
10. A class called Date has been defined to handle Date related functions ie finding the number of days and show
the date when no.of days is given. Another method is required for some job where you input the day number and
it will show you the date in the current year 2023.
You can perform your job by using the following functions/methods of Date given below.
iii) String deleteCharAt(char w,int pos): to delete character w from valid position pos and returns final
sentence without changing any other data.
Write a menu driven program using switch case in main method to implement the above logic for any random
sentence by calling methods.
12. Write a program to accept a sentence which may be terminated by either ‘. ‘ or ?’ or ‘!’ only. Any other character
may be ignored. The words may be separated by more than one blank space and are in UPPER CASE. Perform the
following tasks: (a) Accept a sentence and remove all the extra blank space between two words to a single blank
space. (b) Accept any word from the user along with its position and insert the word in the given position. (The
position is calculated by place value of each word where first word is in position 1, second word in position 2 and so
on). c) Display the modified sentence. Test your program for the following data and some random data.:
Example
INPUT: MORNING WALK IS A BLESSING FOR THE WHOLE DAY.
WORD TO BE INSERTED: TOTAL
WORD POSITION IN THE SENTENCE: 5
OUTPUT: MORNING WALK IS A TOTAL BLESSING FOR THE WHOLE DAY.
13. Write a Java program to check whether a given number is a Disarium number or unhappy number. A
Sum of its digits powered with their respective position is equal to the original number. For
example 175 is a Disarium number :
As 11+32+53= 135
Some other DISARIUM are 89, 175, 518 etc.
A number will be called Disarium if the sum of its digits powered with their respective position is equal with
the number itself.
Happy number: Starting with any positive integer, replace the number
by the sum of the squares of its digits, and repeat the process until the
number equals 1, or it loops endlessly in a cycle which does not
include 1.
An unhappy number is a number that is not happy.
14. Write a program to declare a square matrix M[ ] [ ] of order (N x N) where `N' must be greater than 3 and less
than 10. Allow the user to input positive integers into this matrix.
Perform the following tasks on the matrix:
(a) Sort the boundary elements in ascending order using any standard sorting technique and rearrange them
in the matrix in clockwise manner.
(b) Calculate the product of the non-boundary elements.
(c) Display the original matrix, rearranged matrix and only the non-boundary elements of the rearranged
matrix with their sum.
Test your program for the following data and some random data:
15. Write a program to declare a square matrix M [ ] [ ] of order ‘N’ where ‘N’ must be greater than 3 and
less than Accept the value of N as user input. Display an appropriate message for an invalid
input. Allow the user to accept three different characters from the keyboard and fill the matrix according
to the instruction given below:
(i) Fill the four corners of the square matrix by character 1
(ii) Fill the boundary elements of the matrix (except the four corners) by character 2 (iii) Fill the non-
boundary elements of the matrix by character 3 (iv) Display the matrix formed by the above
instructions Test your program for the following data and some random data: