0% found this document useful (0 votes)
40 views6 pages

Project24 25

Uploaded by

pehiwi7740
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)
40 views6 pages

Project24 25

Uploaded by

pehiwi7740
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/ 6

I.

Number Programs Submission Date: May 31 -2024


1. Write a program to check whether the number is an Autobiographical number or
not. A number is said to be an Autobiographical number if count of its digits is equal
to sum of its digits
Sample Input- 20210
Sample Output 2+0+2+1+0= 5
count of its digits=5
Hence number is Autobiographical number.

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.

5. Xylem and Phloem Number in Java


Xylem and Phloem Number

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. FUNCTION OVERLOADING Submission Date: 1st July


Write a program to overload the function display() for the following tasks:
i) To display the following pattern using the function
void pattern (char ch,int n) where n is the number of lines and ch is the character to
be printed.

*****
****
***
**
*
ii) To display the sum of the following series

S=𝑎2+𝑎4+𝑎6+⋯…..+an terms

2. Design a class to overload the method display( ) as follows


void display(String str, char ch): checks whether the word str contains the letter ch at the
beginning as well as at the end or not. If present, print ‘special word’ otherwise print ‘No special
word’.
void display(String str1, String str2): Checks and prints whether both the words are equal or not.
void display(String str, int n): prints the character present at nth position in the word str.

3. Define a class to overload the method process( ) as follows: [15]


void process( ) – to print the pattern:
5
54
543
5432
void process (int num) – to calculate and display the sum of all factors of the number num.
Input : 24 Output : 1 + 2+ 3+ 4+ 6 + 12 + 24 = 52

III . STRING PROGRAMS Submission Date: 1st September 2024


1. Write a program to input two strings. Check both the strings and remove all common characters
from both the strings. Print both the strings after removing the common characters.

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.

IV. SDA Submission Date: 7th October


1. Write a program to input height of 10 Students in feet ( like 5.8, 6.1, …..) in a single
dimensional array. Sort the heights in ascending order, using bubble sort technique and
display the sorted array.

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

First 100 calls 0.60 / Call


call Next 100 calls 0.80 / call
call Next 100 calls 1.20 /call
call Above 300 calls 1.50 / call
Fixed monthly rental applicable to all consumers: 125
Create an object in the main() method and invoke the above functions to perform the desired task.

4. Define a class Esale described as below:


Member Variables: String name : Name of the item.
int price : Price of the item.
double discount : Discount amount available.
double cost : Amount to be paid after receiving discount.
Member Method:
void accept( ) – accept the details using Scanner as name , price of item.
void compute( )- To calculate the seasonal discount on the item as:
Price DISCOUNT on price
2000 to 30,000 10%
30,001 to 70,000 15%
More than 70,000 20%
void display( ) – To display the details.
Write a main method to create an object of a class and call the above member methods.

5. Define a class BUSCHARGE having the following description


Data Members/Instance Variables:
String name- Name of the passenger
int d -distance travelled
double charge – stores the charges for the distance travelled

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

void printDetails( ) display the details in different lines.


Write a main( ) to create an object and call the functions.

You might also like