0% found this document useful (0 votes)
32 views13 pages

Class XII Project 25-26

The document outlines a Computer Science project for Class XII, detailing various programming tasks including identifying special numbers (Bouncy, Evil, Fascinating), matrix operations, string manipulations, and encryption techniques. It also includes the design of classes for specific functionalities such as converting numbers between bases, counting character frequencies, and generating permutations and combinations. Additionally, it covers the implementation of algorithms for tasks like finding saddle points in matrices and validating dates.

Uploaded by

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

Class XII Project 25-26

The document outlines a Computer Science project for Class XII, detailing various programming tasks including identifying special numbers (Bouncy, Evil, Fascinating), matrix operations, string manipulations, and encryption techniques. It also includes the design of classes for specific functionalities such as converting numbers between bases, counting character frequencies, and generating permutations and combinations. Additionally, it covers the implementation of algorithms for tasks like finding saddle points in matrices and validating dates.

Uploaded by

Rishabh Agarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Class – XII

Subject : Computer Science


Project– 2025-2026

Unit I

1. Input a number and check whether it is a “Bouncy Number” or not.


(A Bouncy Number is a number which is neither in increasing order nor in decreasing
order).
Sample Input : 774361
Sample Output: Bouncy number.
Sample Input : 774321
Sample Output: Not a bouncy number.
2. Input a number and check whether it is a “Evil Number” or not.
( An Evil Number is a positive whole number which has even no. of 1’s in its binary
equivalent)
Sample Input : 9
Sample output: It’s binary equivalent is 1001
No. of 1’s : 2
9 is an Evil Number.

3. Input a number and check whether the number is a “Fascinating Number” or not.

( A Fascinating number are some three digit numbers which exhibit a very interesting
property.)
When a 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 in the number exactly
once, regardless of the no. of zero’s).
Sample Input : n = 192
Sample Output : 192 * 1 = 192
192 * 2 = 384
192 * 3 = 576
Concatinating the numbers : 192384576
192 is a Fascinating number.
Other Fascinaing numbers are: 219,273,327,1902,1920..etc

4. 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 the matrix. Perform the
following tasks on the matrix.

a) Sort non-boundary elements in ascending order using any standard technique and
rearrange them in the matrix.
b) Calculate sum of both the diagonals.
c) Display the original matrix and the rearranged matrix and only the diagonal elements
of the rearranged matrix along with their sum.

5. Given are two strings, input string and a mask string that remove all the characters of
the mask string from the original string.
Example: INPUT: ORIGINALSTRING: communication
MASK STRING : mont
OUTPUT : cuicai
A class StringOp is defined as follows to perform above operation. Some of the
members of the class are given below:
Class name : StringOp
Data members/instance variables:
nstr : to store the original string
msk : to store the mask string
nstr : to store the resultant string
Methods / Member functions:
StringOp() : default constructor to initialize the data member with legal initial value
void accept( ) : to accept the original string str and the mask string msk in lower case
void form() : to form the new string nstr after removal of characters present in
mask from the original string
void display( ) : to display the original string and the newly formed string nstr
Specify the class StringOp giving details of the constructor( ), void accept( ), void
form() and void display( ). Define a main( ) function to create an object and call all
the functions accordingly to enable the task.

6. Design a class MatRev to reverse each element of a matrix.


Example:

Some of the members of the class are given below:


Class name: MatRev
Data members/instance variables:
arr[][] : to store integer elements
m: to store the number of rows
n: to store the number of columns
Member functions/methods:
MatRev(int mm, intnn): parameterized constructor to initialise the data members m
= mm and n = nn
void fillarray(): to enter elements in the array
int reverse(int x): returns the reverse of the number x
void revMat(MatRev P): reverses each element of the array of the parameterized
object and stores it in the array of the current object
void show(): displays the array elements in matrix form.
Define the class MatRev giving details of the constructor ( ), void fillarray (), int
reverse(int), void revMat(MatRev) and void show(). Define the main () function to
create objects and call the functions accordingly to enable the task.

7. A Goldbach number is a positive even integer that can be expressed as the sum of
two odd primes.

Note: All even integer numbers greater than 4 are Goldbach numbers.
Example:
6=3+3
10 = 3 + 7
10 = 5 + 5
Hence, 6 has one odd prime pair 3 and 3. Similarly, 10 has two odd prime pairs, i.e.
3 and 7, 5 and 5.
Write a program to accept an even integer 'N' where N > 9 and N < 50. Find all the
odd prime pairs whose sum is equal to the number 'N'.
Test your program with the following data and some random data:
Example 1
INPUT:
N = 14
OUTPUT:
PRIME PAIRS ARE:
3, 11
7, 7
Example 2
INPUT:
N = 30
OUTPUT:
PRIME PAIRS ARE:
7, 23
11, 19
13, 17
Example 3
INPUT:
N = 17
OUTPUT:
INVALID INPUT. NUMBER IS ODD.
Example 4
INPUT:
N = 126
OUTPUT:
INVALID INPUT. NUMBER OUT OF RANGE.
8. Permutation and Combination of two numbers ‘n’ and ‘r’ are calculated as
n
Pr = ! n / !(n-r)
n
Cr = ! n/ !(n-r)* ! r
where Permutation is denoted as nPr and Combination is denoted as nCr . The nPr
means permutation of ‘n’ and ‘r’ and nCr means combination of ‘n’ and ‘r’ .
Write a program to calculate and display the number of permutation and
combination of two numbers ‘n’ and ‘r’ by using the above formula.
Sample Input : Enter the value of n : 11
Enter the value of r : 10
Sample Output : nPr = 39916800
n
Cr = 11.

9. Write a program in Java to accept a string. Count and display the frequency of each
character present in the string. The character with multiple frequencies should be
displayed only once.

Sample Input : golden jubilee


Sample Output :
Alphabet g o l d e n j u b i
Frequency 1 1 2 1 3 1 1 1 1 1

10. Write a program in Java to accept a String and display all the words present in
the string in PigLatin form.

Example :
Sample Input : THE CAPITAL OF INDIA IS NEW DELHI.
Sample Output : ETHAY APITALCAY OFAY INDIAAY ISAY EWNAY ELHIDAY.

11. A bank intends to design a program to display the denomination of an input


amount, upto 5 digits.The available denomination with the bank are of rupees
1000, 500, 100, 50, 20, 10, 5, 2 and 1.
Design a program to accept the amount from the user and display the break-up in
descending order of denomination. (i.e. preference should be given to the highest
denomination available) along with the total number of notes.[Note: Only the
denomination used should be displayed]. Also print the amount in words according
to the digits.

Example:
INPUT:
14856
OUTPUT:
ONE FOUR EIGHT FIVE SIX
DENOMINATION :
1000 * 14 = 14000
500 * 1 = 500
100 * 3 = 300
50 * 1 = 50
5 * 1=5
1*1=1
TOTAL =14856
TOTAL NUMBER OF NOTES=21.

12. Write a program to accept a sentence and display the new sentence according to
the length of the word.
Sample Input : I Love My Country.
Sample Output : Country Love My I

13. Write a program to accept date in the string format dd/mm/yyyy and accept the
name of the day on the 1st of January of the corresponding year. Find the day for
the given date.
Sample Input : Enter Date : 5/7/2001
st
Day on 1 January : Monday
Sample output:
Day on 5/7/2001 : Thrusday
The program should include the part for validating the inputs namely the date and
the day on 1st January of that year.

14. Accept a string . a word to be deleted along with its position no. delete the word and
display the new sentence.

Sample Input : Enter a Sentence : As You Sow, So So Shall You Reap.


Enter word to be deleted : So
Enter position no. : 13
Sample Output : : As You Sow, So Shall You Reap.

15. Caesar Cipher is an encryption technique which is implemented as ROT13 ('rotate by


13 places'). It is a simple letter substitution cipher that replaces a letter with the letter
13 places after it in the alphabets, with the other characters remaining unchanged.

A/ B/ C/ D/ E/ F/ G/ H/ K/ M/
I/i J/j L/l
a b c d e f g h k m

↕ ↕ ↕ ↕ ↕ ↕ ↕ ↕ ↕ ↕ ↕ ↕ ↕

N/ O/ P/ Q/ R/ S/ U/ V/ W/ X/ Y/
T/t Z/z
n o p q r s u v w x y

Write a program to accept a plain text of length L, where L must be greater than 3
and less than 100.
Encrypt the text if valid as per the Caesar Cipher.
Test your program with the sample data and some random data.
Example 1
INPUT:
Hello! How are you?
OUTPUT:
The cipher text is:
Uryyb! Ubj ner lbh?

Unit II

1. Design a class called Change to convert a decimal number into its equivalent number
in base 16 and vice versa.
For Eg. I) The decimal number 35 is 23 in Hexadecimal
ii) The decimal number 107 is 6B in Hexadecimal
Some members of the class Change is as follows:
Class name : Change
Data members/Instance Variabes :
a[] : An Integer array.
n : Integer to be converted to base 16.
Member Functions :
Change() : constructor to initialize 0 to instance variables.
void input() : To accept an integer to convert
void hexa(String s) : To convert hexadecimal number back to decimal
void decihexa() : To convert decimal integer’n’ to hexadecimal form.

2. Given a matrix of n x n size, the task is to find the saddle point of the matrix. A saddle
point is an element of the matrix such that it is the minimum element in its row and
the maximum in its column.
Examples :
Input: Mat[3][3] = { {1, 2, 3},
{4, 5, 6},
{7, 8, 9}}
Output: 7
7 is minimum in its row and maximum in its column.

Input: Mat[3][3] = {{1, 2, 3},


{4, 5, 6},
{10, 18, 4}}
Output: No saddle point

3. An digit number x is called Keith number if it appears in a special sequence (defined


below) generated using its digits. The special sequence has first n terms as digits of x
and other terms are recursively evaluated as sum of previous n terms.
The task is to find if a given number is Keith Number or not.
Examples:

Input : x = 197
Output : Yes
197 has 3 digits, so n = 3
The number is Keith because it appears in the special
sequence that has first three terms as 1, 9, 7 and
remaining terms evaluated using sum of previous 3 terms.
1, 9, 7, 17, 33, 57, 107, 197, .....

Input : x = 12
Output : No
The number is not Keith because it doesn't appear in
the special sequence generated using its digits.
1, 2, 3, 5, 8, 13, 21, .....

Input : x = 14
Output : Yes
14 is a Keith number since it appears in the sequence,
1, 4, 5, 9, 14, ...

4. Input a paragraph containing ‘n’ number of sentences where 1<= n <4 . The words
are to be separated with a single blank space and are in uppercase . A sentence may
be terminated either with a full stop ‘.’ Or a question mark ‘?’ only. Any other character
may be ignored. Perform the following operations :
a) Accept the number of sentences. If the number of sentences exceeds the limit,
an appropriate error message should be displayed.
b) Find the no. of words in the whole paragraph.
c) Display the words in ascending order of their frequency. Words with same
frequency may appear in any order.
Example 1:
Input : Enter number of sentences = 1
Enter the sentences : TO BE OR NOT TO BE.
Output : Total number of Words : 6
Word Frequency
OR 1
NOT 1
TO 2
BE 2

Example 2:
Input : Enter number of sentences = 3
Enter the sentences : THIS IS A STRING PROGRAM. IS THIS EASY? YES, IT IS.
Output : Total number of Words : 11
Word Frequency
A 1
STRING 1
PROGRAM 1
EASY 1
YES 1
IT 1
THIS 2
IS 3
Example 3:
Input : Enter number of sentences = 5
Output : Sentence limit is 4.

5. A Class DeciOct has been defined to convert a decimal number into its equivalent
octal number. Some of the members of the class are given below:
Class name :DeciOct
Data Members/ instance variables :
n : stores the decimal number.
oct : Stores the octal number.
Member Functions/ Methods :
DeciOct() : Constructor to initialize data members n and
oct with 0.
void getnum(int nn) : assigns nn to n
void deci_oct() : Calculates the octal equivalent of ‘n’ and stores it
in ‘oct’ using the Recursive technique.
void show() : displays the decimal number n, calls the function
deci_oct() and displays its octal equivalent.

Specify the class DeciOct , giving details of the constructor, void getnum(int),
void deci_oct() and void show(). Also define a main() function to create an object
and call the function accordingly to enable the task.

6. A wondrous square is an n by n grid which fulfils the following conditions:

1. It contains integers from 1 to n2, where each integer appears only once.
2. The sum of integers in any row or column must add up to 0.5 x n x (n2 + 1).

For example, the following grid is a wondrous square where the sum of each row or column
is 65 when n=5.

17 24 1 8 15
23 5 7 14 16

4 6 13 20 22

10 12 19 21 3

11 18 25 2 9

Write a program to read n (2 <= n <= 10) and the values stored in these n by n cells and
output if the grid represents a wondrous square.

Also output all the prime numbers in the grid along with their row index and column index
as shown in the output. A natural number is said to be prime if it has exactly two divisors.
For example, 2, 3, 5, 7, 11 The first element of the given grid i.e. 17 is stored at row index 0
and column index 0 and the next element in the row i.e. 24 is stored at row index 0 and
column index 1.

7. Design a program which takes two integer parameters namely number of the day (
between 1 and 366 ) and the year ( in 4 digits ) as inputs and displays the date i.e. day,
month and year.
Also find the corresponding date exactly after (N) days of the present date by accepting
the value of (N) from the use, where the value of (N) is in the limit ( 1 <= N <= 100 )
Design your program which will enable the output in the format given below:
Sample 1
INPUT: DAY NUMBER : 233
YEAR : 2020
DATE AFTER : 17
OUTPUT:
20TH. AUGUST 2020
DATE AFTER 17 DAYS :
6TH. SEPTEMBER 2020
Sample 2
INPUT: DAY NUMBER : 360
YEAR : 2020
DATE AFTER : 45
OUTPUT:
25TH. DECEMBER 2020
DATE AFTER 45 DAYS :
8TH. FEBRUARY 2021
8. Given a time in numbers, we can convert it into words.
Eg. 5:00 – Five O’ clock
5:10 – Ten minutes past five
5:15 – Quarter past five
5:30 – Half past five
5:40 – Twenty minutes to six
5:45 – Quarter to six
5:47 – Thirteen minutes to six.
Write a program which first inputs two integers, the first between 1 to 12(both
inclusive) and second between 0 to 59 (both inclusive) and prints out the time they
represent, in words. Your program should follow the format of the above example.
Sample Input: Enter time : 3,0
Sample output : 3:00 Three O’ clock
Sample Input: Enter time : 7,29
Sample output : 7:29 Twenty nine minutes past seven
Sample Input: Enter time : 6,34
Sample output : 6:34 Twenty six minutes to seven
Sample Input: Enter time : 12,1
Sample output : 12:01 One minute past twelve
Sample Input: Enter time : 12,45
Sample output : 12:45 quarter to one

9. Write a program to input a sentence. Pass it to different methods to carry out the
corresponding tasks mentioned below:
(i) void word(String str) : to display the number of words.
(ii) void display(tring str) : to display number of vowels and uppercase characters.
(iii) void freq(String str) : to display the frequency of each character in the
sentence.
Define the main() function to create an object and call the methods accordingly to
enable the task.
Sample Input : Enter a String: JAVA Langage
Sample Output: No. of words : 2
No. of Vowels : 6
No. of Uppercase characters : 5
Letters Frequency
A 2
J 1
L 1
V 1
a 2
e 1
g 2
n 1
u 1
10. A ‘Sphenic Number’ is a positive integer which has exactly three prime factors. The
first few Sphenic numbers are : 30, 42,6,70,78,102,105,110 ,114,….so on.
Design a class Sphenic to check if a given number is a Sphenic number or not. Specify
the method Check(int n) that accept a number from main method. It displays all the
prime factors. If it contains only three then display ‘Sphenic Number’ otherwise ‘Not a
Sphenic Number’.
Define the main() method to create an object and call the method Check(int n)
accordingly to enable the task.
Sample Input: 30
Sample Output: It’s a Sphenic Number.
30= 2*3*5 . It is a product of exactly three prime numbers.
Sample Input: 60
Sample Output: It’s not a Sphenic Number.
30= 2* 2 *3*5 . It is not a product of exactly three prime numbers.

11. The Consecutive prime numbers are known as Prime Triplets, if they satisfy the
following condition :
(n,n+2,n+6) are all prime numbers Or (n,n+4,n+6) are all prime numbers. Where ‘n’ is
an integer number > 0 , if n=5 then 5, 7 (5+2=7) ,11(5+6=11). Here 5,7,11 are all prime
numbers so 5,7,11 are prime triplets.
If n=7, then 7, 9(7+2=9) ,11(7+6=13) but 9 s not prime.
But n=7, then 7,11(7+4=11), 13(7+6=13) are prime triplets.
Few more examples of prime triplets are:
(5,7,11), (7,11,13),(13,17,19), (17,19,23) , (37,41,43) , (41,43,47),……
Write a program to input a start limit S (>0) and a last limit L (>0). Print all prime
tripets between S and L with suitable message. The prime triplets can be greater or
lesser than L depending on the conditions used for generating prime number
combinations. Print the total number of prime triplets at the end. Use a method that
accepts three integers as parameters and returns 1 if they form a prime triplet
otherwise returns 0.
Sample Input : Enter Start Limit S : 3
Enter End Limit L : 15
Sample Output :
Prime Triplets
5 7 11
7 11 13
13 17 19
Total prime triplet
combinations are : 4

Sample Input : Enter Start Limit S : 10


Enter End Limit L : 50
Sample Output :
Prime Triplets
11 13 17
13 17 19
17 19 23
37 41 43
41 43 47
Total prime triplet
combinations are : 5

12. A superclass Detail has been defined to store the details of a customer. Define a
subclass Bill to compute the monthly telephone charge of the customer as per the chart
is given below:
Number of calls: Rate
1 – 100: Only rental charge
101 – 200: 60 paise per call + rental charge
201 – 300: 80 paise per call + rental charge
Above 300: 1 rupee per call + rental charge
The details of both the classes are given below:
Class name: Detail
Data members/instance variables:
name: to store the name of the customer
address: to store the address of the customer
telno: to store the phone number of the customer
rent: to store the monthly rental charge
Member functions:
Detail (…): parameterized constructor to assign values to data members
void show (): to display the details of the customer
Class name: Bill
Data members/instance variables:
n: to store the number of calls
amt: to store the amount to be paid by the customer
Member functions:
Bill (…): parameterized constructor to assign values to data members of both classes
and to initialize amt = 0.0
void cal(): calculate the monthly telephone charge as per the chart is given above
void show(): displays the details of the customer and amount to be paid.
Specify the class Detail giving details of the constructor, and void show(). Using the
concept of inheritance, specify the class Bill giving details of the constructor(), void cal()
and void show().

13. Link is an entity which can hold a maximum of 100 integers. Link enables the user to
add elements from the rear end and remove integers from the front end of the entity.
Define a class Link with the following details:
Class name: Link
Data Members/instance variables:
Ink []: entity to hold the integer elements,
max: stores the maximum capacity of the entity,
begin: to point to the index of the front end.
end: to point to the index of the rear end.
Member functions:
Link(intmm): constructor to initialize max = mm. begin = 0. end = 0.
void addlink (int v): to add an element from the rear index if possible otherwise display
the message “OUT OF SIZE… ”
int dellink(): to remove and return an element from the front index. if possible
otherwise display the message “EMPTY …” and return – 99.
void display(): displays the elements of the entity.
(a) Specify the class Link giving details of the constructor (int), void addlink (int), int
dellink() and void display ( ).

14. Design a Class Binary and perform the following operations as per user’s choice:
a. Add elements in the tree.
b. Traverse the tree using PreOrder Traversal.
c. Traverse the tree using InOrder Traversal.
d. Traverse the tree using PostOrder Traversal.

15 Write a program which takes N as input, where N is the order of an square matrix.
Generate the spiral matrix of order N.
INPUT:
N=1
OUTPUT:
1

INPUT:
N=3
OUTPUT
123
894
765

INPUT:
N=4
OUTPUT
1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7

INPUT:
N=7
OUTPUT
1 2 3 4 5 6 7
24 25 26 27 28 29 8
23 40 41 42 43 30 9
22 39 48 49 44 31 10
21 38 47 46 45 32 11
20 37 36 35 34 33 12
19 18 17 16 15 14 13

***************************************************************************

You might also like