Professional Documents
Culture Documents
Output
8. WAP to input the names of 10 students in a single dimensional array. Now, enter a student
name and using linear search, search it in the given list of names. If name present, display
“Search Successful” else display “Search unsuccessful”.
9. Write a program to accept 10 different numbers in a Single Dimensional Array (SDA), in
ascending order. Now, enter a number and by using binary search technique, check whether
number is present or not in the list of array elements. If the number is present, then display
the message “Search Successful”, otherwise display “Search Unsuccessful” with their position
in the array.
a[0] a[1] a[2] a[3] a[4] a[5] a[6] a[7] a[8] a[9]
12 31 42 45 64 65 76 81 87 92
Sample Output:
Enter a number to be searched: 87
Search successful and the number is present in position 9.
10. Write a program to accept 10 different integers in a Single Dimensional Array (SDA). Arrange
the numbers in ascending order by using “Selection Sort” technique and display them.
11. Define a class to accept values into a double array of size 20 and print the range of the array,
the range is the difference between the largest and the smallest elements of the array.
12. Write a program in Java to store 10 words in a Single Dimensional Array (SDA). Display only
those words which are palindrome.
Sample Input: MADAM, TEACHER, REFER, SUNLIGHT, NOON, DAD, PLANT, MOM, MAGIC,
CHALK.
Sample Output: MADAM
REFER
NOON
DAD
MOM
13. Design a class to overload the method display() as follows :
void display() – to print the format 1
2 3
4 5 6
7 8 9 10
boolean display(int n) – to check whether the number entered is a Duck Number or not.
[A number is said to be duck if the digit zero (0) is present in it. (The number must not begin
with zero) The program displays the message accordingly.
Sample Input : 5063
Sample Output : It is a Duck Number
Sample Input : 7453
Sample Output : It is not a Duck Number ]
14. Design a class to overload a function area () as follows:
double area(double a, double b, double c) with three double arguments, returns the area of
scalene triangle using the formula:
(𝑎+𝑏+𝑐)
area = √𝑠 (𝑠 − 𝑎) (𝑠 − 𝑏)(𝑠 − 𝑐) where s = 2
double area(int a, int b, int height) with three integer arguments, returns the area of a
trapezium using the formula :
1
area = 2 ∗ ℎ𝑒𝑖𝑔ℎ𝑡 ∗ (𝑎 + 𝑏)
double area(double diagonal1, double diagonal2) with two double arguments, returns the
area of a rhombus using the formula :
1
area = = 2 ∗ 𝑑𝑖𝑎𝑔𝑜𝑛𝑎𝑙1 ∗ 𝑑𝑖𝑎𝑔𝑜𝑛𝑎𝑙2
___________________