Project24 25
Project24 25
2. Emirp number : is a number which is prime when read backwards and frontwards.
For Example : 13 is and emirp number since 13 and 31 both are prime numbers.
First few Emirp Numbers are : 13, 17, 31, 37, 71, 73, 79, 97, 107, 113, 149, 157, 167, 179,
199, 311, 337, 347, 359, 389, 701, 709, 733, 739, 743, 751, 761, 769, 907, 937, 941, 953,
967, 971, 983, 991...
3. Write a Java program to generate and show the first 15 narcissistic decimal
numbers.
A Narcissistic decimal number is a non-negative integer, n that is equal to the sum of
the m-th powers of each of the digits in the decimal representation of n, where m is
the number of digits in the decimal representation of n.
if n is 153
then m , (the number of decimal digits) is 3
we have 13 + 53 + 33 = 1 + 125 + 27 = 153
and so 153 is a narcissistic decimal number .
4. A number is called an Adam number if the square of a number and the square of its
reverse 4.are reverse to each other. Let's understand it through an example.
Adam Number Example
Consider a number (N) 12 and check it is an Adam number or not.
Square of the number (N) = 144
The reverse of the number (N) = 21
Square of the reverse of the number (N) = 441
We observe that the square of 12 and the square of its reverse i.e. 21 are reverse of
each other. Hence, 12 is an Adam number.
Some other Adam numbers are 0, 1, 2, 3, 11, 12, 13, 21, 22, 31, 101, 102, 103, 111, etc5.
A number N will be a xylem number if the sum of its extreme (first and last) digits is
equal to the sum of mean (all digits except first and last) digits. If the sum of extreme
digits is not equal to the sum of mean digits, the number is called phloem number.
*****
****
***
**
*
ii) To display the sum of the following series
S=𝑎2+𝑎4+𝑎6+⋯…..+an terms
2. Write a program to accept a string and convert it into uppercase. Replace all the vowels in the
string with the character ‘#’ and display the new string.
3. Define a class to accept a word using scanner, convert it into uppercase and print the same in
reverse order.
i) Also check for Palindrome word.
ii) count the number of vowels in it.
Input : BEAUTIFUL
Output: LUFITUAEB
vowels 5
4. Define a class to accept a word and convert it to uppercase and replace only the vowels in
a word by the next corresponding vowel and for a new word. That si A→ E, E→I, I→O, O→U
and U→ A [Note: Do not use the library method replace( )]
Sample Input: MES KISHORE KENDRA
Sample Output: MIS KOSHURI KINDRE
5.Write a program to accept a sentence and print only the first letter of each word of the
sentence in capital letters separated by a full stop.
Input Sentence: “World Health Organisation”.
Sample Output: W.H.O.
2. Write a program to store 20 numbers (even and odd numbers) in a Single Dimensional Array
(SDA). Calculate and display the sum of all even numbers and all odd numbers separately.
3. Define a class to perform binary search on a list of integers given below, to search for an
element input by the user ( using Scanner), if it is found display the element along with
its position, otherwise display the message "Search element not found".
arr[ ] = { 2, 5, 7, 10, 15, 20, 29, 30, 46, 50 }
4. Write a program to input 10 elements in a single dimension array of double type, print
those elements that are larger than the average of the elements of the array.
Write a program to input string array and print the longest string in that array.
5. Input a string array of 20 elements of Names and print them in descending order using
selection sort technique .
V. DDA Submission Date: 4th November
1. Define a class to accept values into a 3×3 array and find the sum of all the odd numbers
in the array.
Example:
Input: A[][]={{ 4 ,5, 6}, { 5 ,3, 2}, { 4, 2, 5}};
Output: Sum of odd numbers=5+5+3+5=18
2. Write a program to input numbers into a 5×5 integer matrix and find the sum and average of
all numbers
3. Write a program to print the sum of left and right diagonal elements.
4. Define a class to input and store integer elements in a double dimensional array of size
4x4 and find the sum of each row. Also display the original input array in matrix form.
Input : output :
12 4 8 6 row 1 sum 30
4893 row 2 sum 24
1 14 6 2 row 3 sum 23
7 685 row 4 sum 26
5. Write a program to accept a 2D array of integers and its size as input and display the
element of the middle row and the element of middle column.
VI. User defined programs Submission Date: Dec 24th
1. Define a class Student with the following specifications
Data Members
Purpose String name To store the name of the student
int eng To store marks in English
int hn To store marks in Hindi
int mts To store marks in Maths double total To store total marks
double avg To store average marks
Member Methods Purpose
void accept() To input marks in English, Hindi and Maths
void compute() To calculate total marks and average of 3 subjects
void display() To show all the details viz. name, marks, total and average
Write a program to create an object and invoke the above methods.
2. Design a class named Bill, which will contain the following members:
Data Members:
units,amt of int data type.
Member Functions:
Parameterised constructor to initialise units.
void show( ) to display the contents of units and amt.
void compute(int u ) :calculate the electricity bill with the help of the below mentioned charges:
• 1 to 100 units – Rs.10/unit
• 100 to 200 units – Rs.15/unit
• 200 to 300 units – Rs.20/unit
• above 300 units – Rs.25/unit
In the main( ) create an object and initialise u with any value and calculate amt by invoking the
compute( ) function and display the contents of U an amt using show( ) function.
3. Define a class Bill that calculates the telephone bill of a consumer with the following
description:
Data Members Purpose
int bno- bill number
String name- name of consumer
int call- no. of calls consumed in a month
double amt bill amount to be paid by the person
Member Methods Purpose
Bill()- constructor to initialize data members with default initial value
Bill()- parameterised constructor to accept billno, name and no. of calls consumed
Calculate() -to calculate the monthly telephone bill for a consumer as per the table
Display() t-o display the details
Units consumed Rate
Member Methods:
void accept( ) – To input name and distance travelled
void calc( ) – Calculate the charge based on:
Distance in KMS Charges in Rupees
First 10 KMS 3.00/KM
Next 15 KMS 3.50/KM
More than 25KMS 4.00/KM