Programs For Project 2021-3
Programs For Project 2021-3
1. You are required to design 25 programs minimum for your Computer Science Project. Do any 22
programs from 1-24. 25,26,27 are compulsory.
2. Every program should have algorithm, code and input/output.
3. Do not take font size more than 12. Line spacing should be 1.5. Follow these when you will take the
print out. Printout should be taken after showing the soft copy to me.
4. Project report should contain Index, Acknowledgement and Bibliography.
5. Front page of the project will be given by me after showing the soft copy of the project.
6. Spiral Binding is must.
ISC 2020
1. A prime adam is a positive integer (without leading zeros) which is prime as well as an Adam number.
Prime Number: A number which has only two factors.
Adam Number: The square of a number and the square of its reverse and reverse to each other.
Example: if n=13 and reverse of n=31 then (13)2=169 and (31)2=961 thus 13 is a 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:
Example 1
INPUT: m=5 n=100
OUTPUT: THE PRIME-ADAM INTEGERS ARE: 11 13 31
FREQUENCY OF PRIME-ADAM INTEGERS IS: 3
Example 2
INPUT: m=100 n=200
OUTPUT: THE PRIME-ADAM INTEGERS ARE: 101 103 113
FREQUENCY OF PRIME-ADAM INTEGERS IS: 3
Example 3
INPUT: m=50 n=70
OUTPUT: THE PRIME-ADAM INTEGERS ARE: NIL
FREQUENCY OF PRIME-ADAM INTEGERS IS: 0
Example 4
INPUT: m=700 n=450
OUTPUT: INVALID INPUT
2. Write a program to declare a matrix A[][] of order (M x N) where ‘M’ is the number of rows and N is the number
of columns such that the value of M must be greater than 0 and less than 10 and the value of N must be greater
than 2 and less than 6. Allow the user to input digits (0-7) only at each location such that each row represents an
octal number.
Example 2 3 1 (decimal equivalent of 1st row= 153 i.e. 2x82+3x81+1x80)
4 0 5 (decimal equivalent of 2nd row= 261 i.e. 4x82+0x81+5x80)
1 5 6 (decimal equivalent of 3rd row= 110 i.e. 1x82+5x81+6x80)
Perform the following tasks on the matrix:
(a) Display the original matrix.
(b) Calculate the decimal equivalent for each row and display as per the format given below.
Test your program for the following data:
Example 1
INPUT: M=1
N=3
ENTER ELEMENTS FOR ROW 1: 1 4 4
OUTPUT: FILLED MATRIX DECIMAL EQUIVALENT
144 100
Example 2
INPUT: M=3
N=4
ENTER ELEMENTS FOR ROW 1: 1 1 3 7
ENTER ELEMENTS FOR ROW 2: 2 1 0 6
ENTER ELEMENTS FOR ROW 3: 0 2 4 5
Example 1
INPUT : N=726
OUTPUT : 48 x 15 = 720
6x1 = 6
Remaining boxes = 0
Total number of boxes = 726
Total number of cartons = 16
Example 2
INPUT : N=140
OUTPUT : 48 x 2 = 96
24 x 1 = 24
12 x 1 = 12
6x1 = 6
Remaining boxes 2x1 = 2
Total number of boxes = 140
Total number of cartons = 6
Example 3
INPUT : N=4296
OUTPUT : INVALID INPUT
11. The manager of a company wants to analyze the machine usage from the records to find the utilization of the
machine. He wants to know how long each user used the machine. When the user wants to use the machine he
must login to the machine and after finishing the work he must logoff the machine.
Each log record consists of : User Identification number, Login time and date, Logout time and date
Time consists of: Hours, Minutes
Date consists of: Day, Month
You may assume all logins and logouts are in the same year and there are 100 users at the most. The time
format is 24 hours machine Hours and Minutes.
Design a program:
(a) To find the duration for which each user logged. Output all records along with the duration in hours.
(b) Output the record of the user who logged for the longest duration. You may assume that no user will login
for more than 48 hours.
Test your program with following data:
INPUT: Number of users: 3
USER ID LOGIN TIME LOGIN DATE LOGOUT TIME LOGOUT DATE
149 20:10 20-12 2:50 21-12
173 12:30 20-12 12:30 21-12
142 16:20 20-12 16:30 20-12
OUTPUT:
USER ID LOGIN TIME LOGIN DATE LOGOUT TIME LOGOUT DATE DURATION
149 20:10 20-12 2:50 21-12 6:40
173 12:30 20-12 12:30 21-12 24:00
142 16:20 20-12 16:30 20-12 00:10
39. Write a Program in Java to fill a square matrix of size ‘n*n” in a circular fashion (clockwise) with natural
numbers from 1 to n*n, taking ‘n’ as input.
For example: if n = 4, then n*n = 16, hence the array will be filled as given below.
Note: This program is also known as Spiral Matrix
14. Given a square matrix M [ ] [ ] of order ‘n’. The maximum value possible for ‘n’ is 10. Accept three different
characters from the keyboard and fill the array according to the instruction given below.
Fill the upper and lower elements formed by the intersection of the diagonals by character 1.
Fill the left and right elements formed by the intersection of the diagonals by character 2.
Fill both the diagonals by character 3.
Output the result in format given below:
Example 1
ENTER SIZE : 4
INPUT : FIRST CHARACTER : ‘*’
SECOND CHARACTER : ‘?’
THIRD CHARACTER : ‘#’
OUTPUT :
#**#
?##?
?##?
#**#
Example 2
ENTER SIZE : 5
INPUT : FIRST CHARACTER : ‘$’
SECOND CHARACTER : ‘!’
THIRD CHARACTER : ‘@’
OUTPUT :
@$$$@
!@$@!
!!@!!
!@$@!
@$$$@
Example 3
ENTER SIZE : 65
OUTPUT : SIZE OUT OF RANGE
15. Write a program to declare a square matrix A[][] of order (M x 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:
(a) REARRANGED MATRIX
9 2 1 5
8 3 6 4
15 8 13 11
7 12 23 8
DIAGONAL ELEMENTS
9 5
3 6
8 13
7 8
OUTPUT
19. A sentence is terminated by either “.” ,”!” or “?” followed by space .Input a piece of sentence. Assume that
there will be a maximum of 10 sentences in each block letters.
Write a program to :
(i) Obtain the length of the sentences (measured in words ) and the frequency of vowels in each sentence.
(ii) Generate the output as shown below using the given data.
SAMPLE DATA:
INPUT
HELLO! HOW ARE YOU ? HOPE EVERYTHING IS FINE , BEST OF LUCK
OUTPUT
Sentence No of vowels No of words
1 2 1
2 5 3
3 8 4
4 3 3
INPUT :
M=2500
N=2550
OUTPUT
THE UNIQUE DIGIT INTEGERS ARE :-
2501, 2503, 2504, 2504, 2506 ,2507 ,2508 ,2509, 2510, 2513, 2514, 2516, 2517,
2518, 2519, 2530, 2531, 2534, 2536, 2537, 2538, 2539, 2540, 2541, 2543,
2546, 2547, 2548, 2549.
FREQUENCY OF UNIQUE DIGIT INTEGERS IS : 28
21. A smith number is a composite number , the sum of whose digits is the sum of the digits of its prime factor
obtained as a result of prime factorization (excluding 1) .The first few such numbers are
4,22,27,58,85,94,121….
Example :
a. 666
Prime factors are 2,3,3, and 37
Sum of the digits are (6+6+6)=18
Sum of the digits of the factor (2+3+3+(3+7))=18
b. 4937775
Prime factors are 3,5,5,65837
Sum of the digits are (4+9+3+7+7+7+5)=42
Sum of the digits of the factor are (3+5+5+(6+5+8+3+7))=42
Write a program to input a number and display whether the number is a Smith number or not .
Sample data
Input 94 Output Smith Number
Input 102 Output NOT SMITH number
Input 666 Output SMITH Number
Input 999 Output NOT SMITH Number
22. Write a program that inputs the names of people into two different arrays . A and B . Array A has N numbers
of names while Array B has M numbers of names .with no duplicates in either of them .Merge array A and B
into a single array C . such that the resultant array is sorted alphabetically .
Display all the three arrays A,B, and C sorted alphabetically .Test your program for the given data and some
data
SAMPLE DATA
INPUT
Enter number of names in array A , N = 2
Enter number of names in Array B , M = 3
First array : (A)
Suman
Anil
Second array: (B)
Usha
Sachin
John
OUTPUT Sorted merge array: (C)
Anil
John
Sachin
Suman
Usha
Sorted first array :(A)
Anil
Suman
Sorted second array : (B)
John
Sachin
Usha
23. We would like to generate all possible anagrams of a word . For example if the given word is ‘TOP’,
There will be 6 possible anagrams
TOP
TPO
OPT
OTP
PTO
POT
An anagram must be printed only once .You may output the anagrams in any order .Also output the total
number of anagrams . You may assume that the number of letters ,N ,in the word will be 7 at most , i.e N<=7.
Test your program for the given data and some random data
SAMPLE DATA
INPUT: TO
OUTPUT
TO
OT
Total number of anagrams =2
INPUT : LEAN
OUTPUT:
LEAN LENA LAEN LANE LNEA LNAE EALN EANL ELAN ELNA ENLA ENAL ALNE ALEN ANLE ANEL AENL AELN NLEA
NELA NEAL NALE NAEL
Total number of anagrams = 24
24. Write a program to declare a matrix A[][] of order (m X n) where ‘m’ is the number of rows and ‘n’ is the
number of column such that both m and n must be greater than 2 and less than 20 Allow the user to input
positive integers into this matrix .
(a) Sort the elements of the outer row and column elements in ascending order using any standard sorting
technique and arrange them in an array.
(b) Calculate the sum of the outer row and column elements .
(c) Outputs the original matrix rearranged matrix and only the boundary elements of the rearranged array
with their sum .
Test your program for the following data and some random data
Example:
INPUT :M=3, N=3
1 7 4
8 2 5
6 3 9
OUTPUT:
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 OUTER ROW AND COLUMN ELEMENTS =43
EXAMPLE INPUT :M = 2 N=3
7 1 6
8 9 2
OUTPUT: ORIGINAL MATRIX
7 1 6
8 9 2
REARRANGED MATRIX
1 2 6
9 8 7
BOUNDARY ELEMENTS
1 2 6
9 8 7
SUM OF THE OUTER ROW AND COLUMN ELEMENTS =33
EXAMPLE INPUT: M=4 N=4
9 2 1 5
8 13 8 4
15 6 3 11
7 12 23 8
OUTPUT: ORIGINAL MATRIX
9 2 1 5
8 13 8 4
15 6 3 11
7 12 23 8
REARRANGED MATRIX
1 2 4 5
23 13 8 7
15 6 3 8
12 11 9 8
BOUNDARY MATRIX
1 2 4 5
23 7
15 8
12 11 9 8
SUM OF THE OUTER ROW AND COLUMN ELEMENTS =105
25. Design a Menu Driven Program to perform the following Task. Each Task should be defined in a separate
function.
(a) Add Node in the link list till the user wants
(b) Insertion of new node in the link list at the given position.
(c) Deletion of node in the link list of the given position.
(d) To find the details of the specified node if it is existing in the link list.
(e) Display the details of all the nodes in tabular form.
To perform the above task you can use the following class structure for creating node.
class Node
{
int empid;
String name;
int totalpay;
Node next;
}
26. An interface Data is defined with a data member and a method volume() which returns the volume of the
implementing shape. A super class Base has been defined to contain the radius of a geometrical shape. Define a
sub class CalVol which uses the properties of the interface Data and the class Base and calculates the volume of
a cylinder. The details of the members of the interface and both the classes are given below:
27. A circular queue is a linear data structure which works on the principle of FIFO, enables the user to enter data
from the rear end and remove data from the front end with the rear end connected to the front end to form a
circular pattern. Define a class CirQueue with the following details:
Design the program and also write main function. In the main function design a menu to perform above
methods.