KEMBAR78
Programs For Project 2021-3 | PDF | Login | Matrix (Mathematics)
0% found this document useful (0 votes)
123 views15 pages

Programs For Project 2021-3

computer class 11

Uploaded by

vikrant00450
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)
123 views15 pages

Programs For Project 2021-3

computer class 11

Uploaded by

vikrant00450
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/ 15

INSTRUCTIONS:

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

OUTPUT: FILLED MATRIX DECIMAL EQUIVALENT


1137 607 sum=512+64+24+7=607
2106 1094
0245 165
Example 3
INPUT: M=3
N=3
ENTER ELEMENTS FOR ROW 1: 2 4 8
OUTPUT: INVALID INPUT
Example 4
INPUT: M=4
N=6
OUTPUT: OUT OF RANGE
3. 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 task:
(a) Check for the validity of the accepted sentence only for the terminating character.
(b) Arrange the words in ascending order of their length. If two or more words have same length then sort them
alphabetically.
(c) Display the original sentence along with the converted sentence.
Test your program with following 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
Example 3
INPUT: BE KIND TO OTHERS.
OUTPUT: BE KIND TO OTHERS.
BE TO KIND OTHERS
Example 4
INPUT: NOTHING IS IMPOSSIBLE#
OUTPUT: INVALID INPUT
ISC 2019
4. 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 for the following data and some random data.
Example 1 :
INPUT:
DAY NUMBER : 233
YEAR : 2008
DATE AFTER (N) : 17
OUTPUT : 20 TH AUGUST 2008
DAY AFTER 17 DAYS : 6TH SEPTEMBER 2008
Example 2:
INPUT:
DAY NUMBER : 360
YEAR : 2008
DATE AFTER (N) : 45
OUTPUT : 25TH DECEMBER 2008
DATE AFTER 45 DAYS : 8TH FEBRUARY 2009
5. Write a program to declare a single dimensional array a[] and a square matrix b[][] of size N, where n>2 and
n<10. Allow the user to input positive integers into the single dimension array. Perform the following tasks on
matrix:
(a) Sort the elements of the single dimension array in ascending order using any standard sorting technique and
display the sorted elements.
(b) Fill the square matrix b[][] in the following format.
If the array a[]={5,2,8,1} then after sorting a[]={1,2,5,8} then the matrix b[][] would fill as below:
1258
1251
1212
1125
(c) Display the filled matrix in the above format.
Test your program for the following data and some random data:
Example 1
INPUT: N=3
ENTER ELEMENTS OF SINGLE DIMENSION ARRAY: 3 1 7
OUTPUT: SORTED ARRAY: 1 3 7
FILLED MATRIX
137
131
113
Example 2
INPUT: N=13
OUTPUT: MATRIX SIZE OUT OF RANGE
Example 1
INPUT: N=5
ENTER ELEMENTS OF SINGLE DIMENSION ARRAY: 10 2 5 23 6
OUTPUT: SORTED ARRAY: 2 5 6 10 23
FILLED MATRIX
2 5 6 10 23
2 5 6 10 2
256 2 5
252 5 6
2 2 5 6 10
6. 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:
(a) Check for the validity of the accepted sentence.
(b) Convert the non-palindrome words of the sentence into palindrome words by concatenating the word by its
reverse ( excluding the last character ).
Example: The reverse of the word HELP would be LEH (omitting the last alphabet) and by concatenating
both, the new palindrome word is HELPLEH.
NOTE: The words which end with repeated alphabets, for example ABB would become ABBA and not ABBBA
and XAZZZ becomes XAZZZAX.
(c) Display the original sentence along with the converted sentence.
Test your program for the following data and some random data:
Test your program for the following data and some random data:
Example 1
INPUT: THE BIRD IS FLYING.
OUTPUT: THE BIRD IS FLYING.
THEHT BIRDRIB ISI FLYINGINIYLF
Example 2
INPUT: IS THE WATER LEVEL RISING.
OUTPUT: IS THE WATER LEVEL RISING.
ISI THEHT WATERETAW LEVELEVEL RISINGNISIR
Example 3
INPUT: THIS MOBILE APP LOOKS FINE.
OUTPUT: THIS MOBILE APP LOOKS FINE.
THISIHT MOBILELIBOM APPA LOOKSKOOL FINENIF
Example 4
INPUT: YOU MUST BE CRAZY#
OUTPUT: INVALID INPUT
7. The computer department of the agency of international Espionage is trying to decode intercepted messages.
The agency’s spies have determined that the enemy encodes messages by first converting all characters to their
ASCII values and then reversing the string.
For example, consider A_z (the underscore is just to highlight the space). The ASCII values of A, <space>, z are
65, 32, 122 respectively. Concatenate them to get 6532122, then reverse this to get 2212356 as the coded
message.
Write a program which reads a coded message and decodes it. The coded message will not exceed 200
characters. It will contain only alphabets (A……Z and a…..z) and spaces. ASCII values of A…….Z are 65…..90 and
those of a….z are 97…..122.
Test your program with the following data and some random data:
INPUT : Encoded Message: 2312179862310199501872379231018117927
OUTPUT : THE DECODED MESSAGE : Have A Nice Day
INPUT : Encoded Message: 23511011501782351112179911801562340161171141148
OUTPUT : THE DECODED MESSAGE : Truth Always Wins
8. An encoded text can be decoded by finding actual character for the given ASCII code in the encoded message.
Write a program to input an encoded text having only sequence of ASCII values without any spaces. Any code or
value which is not in the range (65-90 or 97-122 or 32 for space) will be ignored and should not appear in the
output message. Decode the encoded text and print in the form of sentence. The first alphabet of each word
must be in capitals and rest alphabets will be in small only. Any consecutive sets of code 32 will be taken as only
one blank space. The output should be exactly in the following pattern:
INPUT : Coded text : 10665771011153266797868
OUTPUT : Decoded text : James Bond

INPUT : Coded text : 78487367421013232321006589


OUTPUT : Decoded text : Nice Day
9. The result of a quiz competition is to be prepared as follows:
The quiz has five questions with four multiple choices (A,B,C,D) with each question carrying 1 mark for the
correct answer. Design a program to accept the number of participants N such that N must be greater than 3
and less than 11. Create a double dimension array of size (N x 5) to store the answers of each participant row
wise. Calculate the marks for each participant by matching the correct answer stored in a single dimensional
array of size 5. Display the scores for each participant and also the participant having the highest score.
Example : If the value of N=4 then the array would be :
Q1 Q2 Q3 Q4 Q5
Participant 1 A B B C A
Participant 2 D A D C B
Participant 3 A A B A C
Participant 4 D C C A B

Key to the question:


D C C A B
Array entries are line fed (i.e. one entry per line)
Test your program with the following data and some random data:
Example 1
INPUT : N=5
Participant 1 D A B C C
Participant 2 A A D C B
Participant 3 B A C D B
Participant 4 D A D C B
Participant 5 B C A D D
Key : B C D A A
OUTPUT : Scores:
Participant 1 = 0
Participant 2 = 1
Participant 3 = 1
Participant 4 = 1
Participant 5 = 2
Highest score : Participant 5
Example 2
INPUT : N=4
Participant 1 A C C B D
Participant 2 B C A A C
Participant 3 B C B A A
Participant 4 D A D C B
Key : A C D B B
OUTPUT : Scores:
Participant 1 = 3
Participant 2 = 1
Participant 3 = 1
Participant 4 = 3
Highest score : Participant 1
Participant 4
Example 3
INPUT : N= 12
OUTPUT : INPUT SIZE OUT OF RANGE
10. A company manufactures packing cartons in four sizes, i.e. cartons to accommodate 6 boxes, 12 boxes, 24
boxes and 48 boxes. Design a program to accept the number of boxes to be packed (N) by the user (maximum
up to 1000 boxes)and display the break-up of the cartons used in descending order of capacity (i.e. preference
should be given to the highest capacity available, and if boxes left are less than 6, an extra carton of capacity 6
should be used.)
Test your program with the following data and some random data:

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

The user who logged in for longest duration:


173 12:30 20-12 12:30 21-12 24:00
12. Write a Program in Java to input a number and check whether it is a Keith Number or not.
Note:A Keith Number is an integer N with ‘d’ digits with the following property:
If a Fibonacci-like sequence (in which each term in the sequence is the sum of the ‘d’ previous terms) is formed,
with the first ‘d’ terms being the decimal digits of the number N, then N itself occurs as a term in the sequence.
For example, 197 is a Keith number since it generates the sequence
1, 9, 7, 17, 33, 57, 107, 197, ………..
Some keith numbers are: 14 ,19, 28 , 47 , 61, 75, 197, 742, 1104, 1537……………
13. A square matrix is said to be a Magic Square, if the sum of each row, each column and each diagonal is same.
Write a program to enter an integer number ‘n’. Create a magic square of size ‘n*n’. Finally, print the
elements of the matrix as Magic Square.
Note: n <= 5
Sample Input: Enter the size of the matrix : 4
Sample Output: The Magic Matrix of size 4×4 is:

Sample Input: Enter the size of the matrix : 5


Sample Output: The Magic Matrix of size 5×5 is:

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

SUM OF THE DIAGONAL ELEMENTS = 59


16. 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 an 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
17. 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 :
(i) Accept the number of sentences. If the number of sentences exceeds the limit, an appropriate error message
must be displayed.
(ii) Find the number of words in the whole paragraph.
(iii) 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 sentences
TO BE OR NOT TO BE.
OUTPUT: Total number of words: 6
WORD FREQUENCY
OR 1
NOT 1
TO 2
BE 2
18. Given a square matrix list [] [] of order ‘n’ . The maximum value possible for ‘n’ is 20 .Input the value for ‘n’
and the positive integer in the matrix and perform the following task.
(i) Display the original matrix .
(ii) Print the row and column position of the largest element of the matrix .
(iii) Print the row and column position of the second largest element of the matrix
(iv) Sort the element of the rows in the ascending order and display the new matrix.
SAMPLE DATA
INPUT N=3
List [][]

OUTPUT

The largest element 9 is in row 3 and column 1


The second Largest element 8 is in row 3 and column 2
SORTED LIST

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

Sentence No of words / Vowels


1 VVVVVV
WWW
2 VVVVVVVVVVVVVVV
WWWWWWWWW
3 VVVVVVVVVVVVVVVVVVVVVVVV
WWWWWWWWWWWWWW
4 VVVVVVVVV
WWWWWWWWW
Scale used 1:3
20. A unique digit integer is a positive integer (without leading zeros) with no duplicate digits . For example 7
,135, 214 are all unique digit integers whereas 33,3121,300 are not. Given two positive integers m and n
where m<n write a program to determine how many unique -digit integers are there in the range between m
and n ( both inclusive ) and output them.
The input contains two positive integers m and n . Assume m<30000 and n<30000 . You are to output the
number of unique -digit integer in the specified range along with their values in the format specified below
SAMPLE DATA:
INPUT :
M=100
N=120
OUTPUT :
THE UNIQUE DIGIT INTEGERS ARE :-
102, 103, 104, 105, 106, 107, 108, 109, 120
FREQUENCY OF UNIQUE DIGIT INTEGERS IS : 9

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:

Interface name : Data


Data member :
double pi : initialize pi=3.142
Member functions/methods :
double volume()

Class name : Base


Data member :
rad : to store the radius in decimal
Member functions/methods :
Base(……) : parameterized constructor to initialize the data member.
void show() : displays the radius with an appropriate message.
Class name : CalVol
Data member :
ht : to store the height in decimal
Member functions/methods :
Base(……) : parameterized constructor to initialize the data members of both the
classes.
double volume() : calculates the volume of a sphere.
void show() : displays the radius with an appropriate message.

Design the program using the concept of Inheritance.

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:

Class name : CirQueue


Data members/instance variables:
cq[] : array to store the integers.
cap : stores the maximum capacity of the array.
front : to point the index of the front end.
rear : to point the index of the rear end
Member functions:
CirQueue(int max) : constructor to initialize the data member cap=max, front=0 and rear=0.
void push(int n) : to add integer in the queue from the rear end if possible, otherwise
display the message “QUEUE IS FULL”.
int pop() : removes and returns the integer from the front end of the queue if any,
else returns -9999.
void show() : displays the queue elements.

Design the program and also write main function. In the main function design a menu to perform above
methods.

You might also like