SUMMER HOLIDAY ASSIGNMENT JULY/AUGUST 2025
CLASS: 12 RECORD QUESTIONS
COMPUTER SCIENCE
Do all the programs in BlueJ (including Algorithms)
Submit it on or before 1st September 2025
Number Checking Programs
1. Write a Program in Java 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.Example Consider the number 192
a. 192 x 1 = 192
b. 192 x 2 = 384
c. 192 x 3 = 576
Concatenating the results: 192 384 576 .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.
2. WAP to generate Pronic Number/oblong number/ rectangular number / heteromecic number(Pronic Number : A
pronic number, oblong number, rectangular number or heteromecic number, is a number which is the product of
two consecutive integers, that is, n (n + 1). The first few pronic numbers are: 0, 2, 6, 12, 20, 30, 42, 56, 72, 90,
110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420, 462 …)
3. A Prime-Adam integer is a positive integer (without leading zeros) which is a prime as well as an Adam number.
Prime number: A number which has only two factors, i.e. 1 and the number itself.
Example: 2, 3, 5, 7 ... etc.
Adam number: The square of a number and the square of its reverse are reverse to each other.
Example: If n = 13 and reverse of 'n' = 31, then,
(13)2 = 169
(31)2 = 961 which is reverse of 169, thus 13, is an Adam number.
Accept two positive integers m and n, where m is less than n as user input. Display all Prime-Adam integers
that are in the range between m and n (both inclusive) and output them along with the frequency, in the
format given below:
Test your program with the following data and some random data:
Example 1
INPUT:
m=5
n = 100
OUTPUT:
THE PRIME-ADAM INTEGERS ARE:
11 13 31
FREQUENCY OF PRIME-ADAM INTEGERS IS: 3
4. A prime palindrome integer is a positive integer (without leading zeros) which is prime as well as a
palindrome.
Given two integers m and n, where m < n, write a program to determine how many prime-palindrome
integers are there in the range between m and n (both inclusive) and output them.
The input contains two positive integers m and n where m < 3000 and n < 3000. Display the number of
prime-palindrome integers in the specified range along with their values in the format specified below:
Test your program with the sample data and some random data:
Example 1
INPUT:
m = 100
N = 1000
OUTPUT:
THE PRIME PALINDROME NUMBERS ARE:
101, 131, 151, 181, 191, 313, 353, 373, 383, 727, 757, 787, 797, 919, 929
FREQUENCY OF PRIME PALINDROME INTEGERS: 15
Example 2
INPUT:
m = 100
n = 5000
OUTPUT: OUT OF RANGE
5. Write a program to input a number and check whether it is 'Magic Number' or not. Display the message
accordingly.
A number is said to be a magic number if the eventual sum of digits of the number is one.
Sample Input : 55
Then, 5 + 5 = 10, 1 + 0 = 1
Sample Output: Hence, 55 is a Magic Number.
Similarly, 289 is a Magic Number
6. 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.
Write a program in java to accept a number. Check and display whether it is a Bouncy number or not.
7. A Circular Prime is a prime number that remains prime under cyclic shifts of its digits. When the leftmost digit
is removed and replaced at the end of the remaining string of digits, the generated number is still prime. The
process is repeated until the original number is reached again.
A number is said to be prime if it has only two factors 1 and itself.
Example:
131
311
113
Hence, 131 is a circular prime.
Accept a positive number N and check whether it is a circular prime or not. The new numbers formed after
the shifting of the digits should also be displayed.
Test your program with the following data and some random data:
Example 1
INPUT:
N = 197
OUTPUT:
197
971
719
197 IS A CIRCULAR PRIME.
8. 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
Date checking Programs
9. Write a program to input two valid dates, each comprising of Day (2 digits), Month (2 digits) and Year (4
digits) and calculate the days elapsed between both the dates.
Test your program for the following data values:
FIRST DATE:
Day: 24
Month: 09
Year: 1960
SECOND DATE:
Day: 08
Month: 12
Year: 1852
Output: xxxxxxxx
(these are actual number of days elapsed)
10. Design a program to accept a day number (between 1 and 366), year (in 4 digits) from the user to generate
and display the corresponding date. Also, accept 'N' (1 <= N <= 100) from the user to compute and display
the future date corresponding to 'N' days after the generated date. Display an error message if the value of
the day number, year and N are not within the limit or not according to the condition specified.
Test your program with the following data and some random data:
Example 1
INPUT:
DAY NUMBER: 255
YEAR: 2018
DATE AFTER (N DAYS): 22
OUTPUT:
DATE: 12TH SEPTEMBER, 2018
DATE AFTER 22 DAYS: 4TH OCTOBER, 2018
11.Design a class Convert to find the date and the month from a given day number for a particular year.
Example: If day number is 64 and the year is 2020, then the corresponding date would be: March 4,
2020 i.e. (31 + 29 + 4 = 64). Some of the members of the class are given below:
Class name: Convert
Data members/instance variables:
n: integer to store the day number.
d: integer to store the day of the month (date).
m: integer to store the month.
y: integer to store the year.
Methods/Member functions:
Convert(): constructor to initialize the data members with legal initial values.
void accept(): to accept the day number and the year.
void dayToDate(): converts the day number to its corresponding date for a particular year and
stores the date in ‘d’ and the month in ‘m’.
void display(): displays the month name, date and year.
Specify the class Convert giving details of the constructor, void accept(), void dayToDate() and void
display(). Define a main() function to create an object and call the functions accordingly to enable
the task.
12. Write a program to accept a date in the string format dd/mm/yyyy and accept the name of the day on 1st of
January of the corresponding year. Find the day for the given date.
Example:
Input:
Date: 5/7/2001
Day on 1st January : MONDAY
Output:
Day on 5/7/2001 : THURSDAY
String programs
13. Write a program that reads a string and a character. Each occurrence of the given character (regardless of its
case) is converted to opposite case.
INPUT: AabrAcadabrA and ‘a’
OUTPUT: aAbracAdAbra ( see each ‘a’ or ‘A’ is converted to opposite case ie. upper to lower or vice-versa
14. Write a program to Input a word in uppercase and check for the position of the first occurring vowel and
perform the following operation.
(i) Words that begin with a vowel are concatenated with “Y”.
For example, EUROPE becomes EUROPEY.
(ii) Words that contain a vowel in-between should have the first part from the position of the vowel till
the end, followed by the part of the string from beginning till the position of the vowel and is
concatenated by “C”.
For example, PROJECT becomes OJECTPRC.
(iii) Words which do not contain a vowel are concatenated with “N”.
For example, SKY becomes SKYN.
15. A class TheString accepts a string of a maximum of 100 characters with only one blank space between the
words. Some of the members of the class are as follows:
Class name : TheString
Data member/instance variable:
str : to store a string
len : integer to store the length of the string
wordcount : integer to store the number of words
cons : integer to store the number of consonants
Member functions/methods:
TheString( ) : default constructor to initialize the data members
TheString( String ds) : parameterized constructor to assign str=ds
void countFreq() : to count the number of words and the number of consonants and store them in
wordcount and cons respectively
void Display( ) : to display the original string, along with the number of words and the number of consonants
Specify the class TheString giving the details of the constructors, void countFreq() and void Display( ). Define
the main( ) function to create an object and call the functions accordingly to enable the task.
16. A class ConsChange has been defined with the following details:
Class name : ConsChange
Data members/instance variables:
word : stores the word
len : stores the length of the word
Member functions/methods:
ConsChange( ) : default constructor
void readword( ) : accepts the word in lowercase
void shiftcons( ) : shifts all the consonants of the word at the beginning followed by the vowels (e.g. spoon
becomes spnoo)
void changeword( ) : changes the case of all occurring consonants of the shifted word to uppercase, for e.g.
(spnoo becomes SPNoo)
void show( ) : displays the original word, shifted word and the changed word Specify the
class ConsChange giving the details of the constructor(),void readword( ), void shiftcons( ), void changeword(
) and void show( ). Define the main( ) function to create an object and call the functions accordingly to enable
the task.
17. Write a program to accept a sentence as input. The words in the string are to be separated by a blank. Each
word must be in upper case. The sentence is terminated by either “.”,”!” or “?”. Perform the following tasks:
(i) Obtain the length of the sentence. (measured in words)
(ii) Arrange the sentence in alphabetical order of the words.
Test your program with the sample data and some random data:
Example 1:
INPUT: NECESSITY IS THE MOTHER OF INVENTION.
OUTPUT:
Length: 6
Rearranged Sentence:
INVENTION IS MOTHER NECESSITY OF THE
18. Write a program to accept a sentence which may be terminated by either '.', '?' or '!' only. The words are to
be separated by a single blank space and are in UPPER CASE.
Perform the following tasks:
Check for the validity of the accepted sentence only for the terminating character.
Arrange the words in ascending order of their length. If two or more words have the same length, then sort them
alphabetically.
Display the original sentence along with the converted sentence.
Test your program for the following data and some random data:
Example 1:
INPUT:
AS YOU SOW SO SHALL YOU REAP.
OUTPUT:
AS YOU SOW SO SHALL YOU REAP.
AS SO SOW YOU YOU REAP SHALL
Example 2:
INPUT:
SELF HELP IS THE BEST HELP.
OUTPUT:
SELF HELP IS THE BEST HELP.
IS THE BEST HELP HELP SELF
19. Write a program to accept a sentence which may be terminated by either '.' or '?' only. The words are to be
separated by a single blank space. Print the error message if the input does not terminate with '.' or '?'.
You can assume that no word in the sentence exceeds 15 characters, so that you get a proper formatted output.
Perform the following tasks:
(i) Convert the first letter of each word to uppercase.
(ii) Find the number of vowels and consonants in each word and display them with proper headings along with
the words.
Test your program with the following inputs:
Example 1
INPUT: Intelligence plus character is education.
OUTPUT:
Intelligence Plus Character Is Education.
Word Vowels Consonants
Intelligence 5 7
Plus 1 3
Character 3 6
Is 1 1
Education 5 4
Example 2
INPUT: God is great.
OUTPUT:
God Is Great.
Word Vowels Consonants
God 1 2
Is 1 1
Great 2 3
Example 3
INPUT: All the best!
OUTPUT:
Invalid Input
20. Write a program to print the initials of string recursively
A class Initials Print has been defined to print the initials of the name. Some of the members of the class are
given below:
Class name : InitialsPrint
Data members/instance variables:
String initials : to store the initials of the name
Member functions:
initialsPrint(): constructor to assign blank to initials.
void initRecursive(String s, int i): to store the initials of the name in the variable initials as shown in the
sample output using Recursive technique.
Sample Input: Narendra Damodardas Modi
Sample Output: N.D.M.
display(): to accept full name from the user and print the initials of string as shown in the sample output.
Specify the class Initials Print the initials of string giving details of the constructor, void initRecursive (String s,
int i) and void display (). Write main () to create and object and call the respective methods.
21. 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 uppercase.
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.
22. Write a program to accept a paragraph containing two sentences only. The sentences may be terminated by
either '.', '?' or '!' only. Any other character may be ignored. The words are to be separated by a single blank
space and must be in uppercase.
Perform the following tasks:
(a) Check for the validity of the accepted paragraph for the number of sentences and for the
terminating character.
(b) Separate the two sentences from the paragraph and find the common words in the two sentences
with their frequency of occurrence in the paragraph.
(c) Display both the sentences separately along with the common words and their frequency, in the
format given below.
Test your program for the following data and some random data:
EXAMPLE
INPUT:
IS IT RAINING? YOU MAY GET WET IF IT IS RAINING.
OUTPUT:
IS IT RAINING?
YOU MAY GET WET IF IT IS RAINING.
COMMON WORDS FREQUENCY
IS 2
IT 2
RAINING 2
23. Write a program to accept a sentence which may be terminated by either’.’, ‘?’or’!’ only. The words may be
separated by more than one blank space and are in UPPER CASE.
Perform the following tasks:
(a) Find the number of words beginning and ending with a vowel.
(b) Place the words which begin and end with a vowel at the beginning, followed by the remaining words as
they occur in the sentence.
Test your program for words that start and end with a vowel with the sample data and some random data:
words that start and end with a vowel
Example 1
INPUT: ANAMIKA AND SUSAN ARE NEVER GOING TO QUARREL ANYMORE.
OUTPUT: NUMBER OF WORDS BEGINNING AND ENDING WITH A VOWEL= 3
ANAMIKA ARE ANYMORE AND SUSAN NEVER GOING TO QUARREL
Array Programs
24. A class Circular has been signed to print a set of elements in a circular fashion. For example, if input is 1,2,3,4
output should be:
1,2,3,4
4,1,2,3
3,4,1,2
2,3,4,1
Class name: CircularShift
Data members/ instance variables:
list[ ]: store the elements
size: to store the number of elements
Member functions:
void input(): to input the size and the elements in the array
void Circular_Shift():to shift the elements of the array one place to the right. First element comes to the second
position, second element to the third and ultimately the last element comes to the first position and so on.
void reverse(): reverse the array without using any temporary variable to swap its elements.
void display(): to display the array in a circular fashion.
Specify the class CircularShift giving details of the constructor and member
functions void input(), void Circular_Shift(), void reverse(). void display() define the main() function to create
an object and call the functions accordingly.
25. A class matrix contains an integer array of order [m * n]. The maximum value possible for both m and n is 10.
Design a class matrix to find the difference of the two matrices. The details of the members of the class are
given below:
Class name : matrix
Data members:
atm[][] : to store the matrix
m, n : integer to store the number of rows and columns
Member functions:
Matrix(…..) : initialize m, n and to allocate memory to member array
void fnGet() : to fill the member array
void fnDisplay() : to show the member matrix
Matrix fnSub(Matrix A) : Subtract the current object from the matrix of parameterized object and return the
resulting object.
Specify the class Matrix, Define main (), giving the details of the above member data and methods only.
26. Write a program to declare a square matrix A[][] of order (M × M) where 'M' 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:
Sort the non-boundary elements in ascending order using any standard sorting technique
and rearrange them in the matrix.
Calculate the sum of both the diagonals.
Display the original matrix, rearranged matrix and only the diagonal elements of the
rearranged matrix with their sum.
27. Write a program to declare a square matrix A[][] of order MxM where ‘M’ is the number of rows and the
number of columns, such that M must be greater than 2 and less than 10. Accept the value of M as user input.
Display an appropriate message for an invalid input. Allow the user to input integers into this matrix.
Perform the tasks:
Display the original matrix
Rotate the matrix 90 clockwise as shown below:
original matrix
1 2 3
4 5 6
7 8 9
Rotated matrix
7 4 1
8 5 2
9 6 3
Find the sum of the elements of the four comers of the matrix.
28. Write a program to declare a matrix A[][] of order (MXN) where ‘M’ is the number of rows and ‘N’ is the
number of columns such M and N must be greater than w and less than 20
Allow the user to input integers into this matrix. Perform the following tasks on the matrix:
(a) Display the input matrix
(b) Find the maximum and minimum value in the matrix and display them along with their position.
(c) Sort the elements of the matrix in ascending order using any standard sorting technique and
rearrange them in the matrix.
HAPPY VACATION STAY SAFE