St.
Stephen’s Group of Schools
FINAL ASSIGNMENT 2025 – 2026
Class: XI
Subject: Computer Science
Question 12:
Write a program to convert decimal to hexadecimal.
Question 13:
Write a Program in Java to input a number and check whether it is a
Harshad Number Or NivenNumber or not..
Harshad Number:
A Harshad number (or Niven number), is an integer (in base 10) that
isdivisible by the sum of its digits.
Question 14:
An emirp number is a number which is prime backwards and forwards.
Example: 13 and 31 are both prime numbers. Thus, 13 is an emirp
number.
Design a class Emirp to check if a given number is Emirp number or not.
Some of the members of the class are given below:
Class name: Emirp
Data members/instance variables:
n: stores the number
rev: stores the reverse of the number
f: stores the divisor
Member functions:
Emirp(int nn): to assign n = nn, rev = 0 and f = 2
int isprime(int x): check if the number is prime using the recursive
technique and return 1 if prime otherwise return 0
void isEmirp(): reverse the given number and check if both the original
number and the reverse number are prime, by invoking the function
isprime(int) and display the result with an appropriate message
Specify the class Emirp giving details of the constructor(int), int isprime
(int) and void isEmirp(). Define the main function to create an object and
call the methods to check for Emirp number.
Question 15:
A class SeriesSum is designed to calculate the sum of the following
series:
Some of the members of the class are given below:
Class name: SeriesSum
Data members/instance variables:
x: to store an integer number
n: to store the number of terms
sum: double variable to store the sum of the series
Member functions:
SeriesSum(int xx, int nn): constructor to assign x=xx and n=nn
double find fact(int m): to return the factorial of m using the recursive
technique.
double find power(int x, int y): to return x raised to the power of y using
the recursive technique.
void calculate(): to calculate the sum of the series by invoking the
recursive functions respectively
void display(): to display the sum of the series
Specify the class SeriesSum, giving details of the constructor(int, int),
double find fact(int),
double find power(int, int), void calculate() and void display(). Define the
main() function to create an object and call the functions accordingly to
enable the task.
Question 16:
The potential of a word is found by adding the ASCII value of the
alphabets.
(ASCII values of A to Z are 65 to 90).
Example: BALL
Potential = 66 + 65 + 76 + 76 = 283
Write a program to accept a sentence which may be terminated by either
“.”,“?
” or “ ! ” only. The words of sentence are separated by single blank
space and
are in UPPER CASE. Decode the words according to their potential and
arrange
them in ascending order of their potential strength.
Test your program with the following data and some random data:
Example 1:
INPUT: HOW DO YOU DO?
OUTPUT:
HOW = 238
DO = 147
YOU = 253
DO = 147
DO DO HOW YOU
Example 2:
INPUT: LOOK BEFORE YOU LEAP.
OUTPUT:
LOOK = 309
BEFORE = 435
YOU = 253
LEAP = 290
YOU LEAP LOOK BEFORE
Example 3:
INPUT: HOW ARE YOU#
OUTPUT: INVALID INPUT
Question 17:
Design a class Exchange to accept a sentence and interchange the first
alphabet with the last alphabet for each word in the sentence, with
single-letter word remaining unchanged. The words in the input
sentence are separated by a single blank space and terminated by a full
stop.
Example:
Input: It is a warm day.
Output: tI si a mraw yad
Some of the data members and member functions are given below:
Class name: Exchange
Data members/instance variables:
sent: stores the sentence
rev: to store the new sentence
size: stores the length of the sentence
Member functions:
Exchange(): default constructor
void readsentence(): to accept the sentence
void exfirstlast(): extract each word and interchange the first and last
alphabet of the word and form a new sentence rev using the changed
words
void display(): display the original sentence along with the new changed
sentence.
Specify the class Exchange giving details of the constructor ( ), void
readsentence (), void exfirstlast () and void display (). Define the main ()
function to create an object and call the functions accordingly to enable
the task.
Question 18:
Input a sentence from the user and count the number of times, the
words “an” and “and” are present in the sentence. Design a class
Frequency using the description given below:
Class name: Frequency
Data members/variables:
text: stores the sentence
countand: to store the frequency of the word “and”
countan: to store the frequency of the word “an”
len: stores the length of the string
Member functions/methods:
Frequency(): constructor to initialize the instance variables
void accept(String n): to assign n to text, where the value of the
parameter n should be in lower case.
void checkandfreq(): to count the frequency of “and”
void checkanfreq(): to count the frequency of “an”
void display(): to display the number of “and” and “an” with appropriate
messages.
Specify the class Frequency giving details of the constructor(), void
accepts(String), void checkandfreq(), void checkanfreq() and void
display(). Also, define the main() function to create an object and call
methods accordingly to enable the task.
Question 19:
A sequence of Fibonacci strings is generated as follows:
S0 = “a”, SF = “b”, Sn = S(n-1) + S(n-2) where ‘+’ denotes
concatenation. Thus the sequence is:
a, b, ba, bab, babba, babbabab,……. n terms.
Design a class FiboString to generate Fibonacci strings. Some of the
members of the class are given below:
Class name: FiboString
Data members/instance variables:
x: to store the first string
y: to store the second string
z: to store the concatenation of the previous two strings
n: to store the number of terms
Member functions/methods:
FiboString(): constructor to assign x=”a”, y=”b” and z=”ba”
void accept(): to accept the number of terms ‘n’
void generate(): to generate and print the Fibonacci strings. The sum of
(‘+’ ie concatenation) first two strings is the third string. Eg. “a” is first
string, “b” is second string then the third will be “ba”, and fourth will be
“bab” and so on.
Specify the class FiboString, giving details of the constructor(), void
accept() and void generate(). Define the main() function to create an
object and call the functions accordingly to enable the task.
Question 20:
Design a class ROUND which will shift all the letters in a word by one
index towards left and the first letter will join at the end.
Example: AFRICA will become FRICAA.
The details of the members of the class are given below:
Class name : ROUND
Data members/instance variables:
Wrd : stores the input word in uppercase
Res : stores the output word
Methods/Member functions:
ROUND( ) : default constructor
void acceptword( ) : to accept the word in uppercase
String round(String s) : shift the letters of s as directed above
void display( ) : displays both the words
Specify the class ROUND giving details of the constructor, void
acceptword(), String round(String) and void display( ). Define the main( )
function to create an object and call the functions accordingly to enable
the task.
Question 21:
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 the values of
both
'm' and 'n' must be greater than 2 and less than 10. Allow the user to
input
integers into this matrix. Perform the following tasks on the matrix:
1. Display the original matrix.
2. Sort each row of the matrix in ascending order using any standard
sorting technique.
3. Display the changed matrix after sorting each row.
Test your program for the following data and some random data:
Example 1
INPUT:
M=4
N=3
ENTER ELEMENTS OF MATRIX:
11 -2 3
5 16 7
904
318
OUTPUT:
ORIGINAL MATRIX
11 -2 3
5 16 7
904
318
MATRIX AFTER SORTING ROWS
-2 3 11
5 7 16
049
138
Example 2
INPUT:
M=3
N=3
ENTER ELEMENTS OF MATRIX
22 5 19
7 36 12
9 13 6
OUTPUT:
ORIGINAL MATRIX
22 5 19
7 36 12
9 13 6
MATRIX AFTER SORTING ROWS
5 19 22
7 12 36
6 9 13
Example 3
INPUT:
M = 11
N=5
OUTPUT:
MATRIX SIZE OUT OF RANGE.
Question 22:
Write a program in Java to store the elements in two different double
dimensional arrays (in matrix form) A and B each of order 4 x 4. Find the
product of both the matrices and store the result in matrix C. Display the
elements of matrix C.
Note:
Two matrixes can be multiplied only if the number of columns of the first
matrix must be equal to the number of rows of the second matrix.
Sample Input: Matrix A
3 2 1 2
6 4 5 0
7 -1 0 2
4 3 1 1
Sample Input: Matrix B
-2 -4 -1 0
3 6 -5 2
5 3 4 6
0 -2 2 5
Sample Output: Matrix C
5 -1 -5 20
25 15 -6 38
-17 -38 2 -8
6 3 -13 17
Question 23:
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 10. 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) Create and display the mirror image matrix
(c) Calculate the sum of the four corner elements of the matrix and
display
Test your program for the following data and some random data:
Example 1
INPUT:
M=3
N=4
8 7 9 3
-2 0 4 5
1 3 6 -4
OUTPUT:
ORIGINAL MATRIX
8 7 9 3
-2 0 4 5
1 3 6 -4
MIRROR MATRIX
3 9 7 8
5 4 0 -2
-4 6 3 1
SUM OF THE CORNER ELEMENTS = 8
Example 2
INPUT:
M=2
N = 10
OUTPUT:
INVALID INPUT
Question 24:
An Evil number is a positive whole number which has even number of
1's in its binary equivalent. Example: Binary equivalent of 9 is 1001,
which contains even number of 1's. A few evil numbers are 3, 5, 6, 9….
Design a program to accept a positive whole number and find the binary
equivalent of the number and count the number of 1's in it and display
whether it is a Evil number or not with an appropriate message. Output
the result in format given below:
Example 1
Input: 15
Binary Equivalent: 1111
No. of 1's: 4
Output: Evil Number
Example 2
Input: 26
Binary Equivalent: 11010
No. of 1's: 3
Output: Not an Evil Number
Question 25:
A class Encode has been defined to replace only the vowels in a word by the
next
corresponding vowel and form a new word.
i.e. A → E, E → I, I → O, O → U, U → A and
a → e, e → i, i → o, o → u, and u → a
Example: Input: Institution
Output: Onstotatoun
Some of the members of the class are given below:
Class name : Encode
Data members/instance variables:
word : to store a word
length : integer to store the length of the word
new_word : to store the encoded word
Methods / Member functions:
Encode( ) : default constructor to initialize data members
with legal initial values
void acceptWord( ) : to accept a word
void nextVowel( ) : to replace only the vowels from the word stored
in ‘word’ by the next corresponding vowel and
to assign it to ‘newword’, with the remaining
alphabets unchanged
void display( ) : to display the original word along with the
encrypted word
Specify the class Encode giving details of the constructor( ), void acceptWord(
),
void nextVowel( ) and void display( ). Define a main ( ) function to create an
object and
call the functions accordingly to enable the task.
INSTRUCTIONS
1. Program Questions must be printed
2. Written Algorithm for each program separately and attached with
before starting each programs.
3. Print the codes with comment lines in BlueJ Environment only and
pasted on right side Do Not take any snapshot or screenshot of the code
4. Print the Outputs in BlueJ Environment only and must be printed , Do
not take any snapshot or screenshot of the code
5. Variables list must be Printed and the headings are as follows:
- Variable Name Type Purpose
6. Function list must be handwritten and the headings are as follows.
Function Name Return Type Argument Name Argument Type
Purpse
7. Finally write down the conclusion about your assignment and specify
the software name with version and the total time taken to complete the
task.
8. Use only A4 pages to complete the assignment
9. Only print all the documents
10. Prepare an INDEX of this assignment only printout is acceptable top
of the first page