Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Question 2 [10] Define a class to initialize array pr [ ] to store the first ten prime numbers.

Accept a number from the user to find it in the array using binary search technique. If it is
found in the array print it along with its position in the array. Otherwise, display the
message “Number not existing in the array.” Also, print the number of prime numbers
falling below that number in the array, with an appropriate message.

Question 3 [10] Define a class to declare a character array of size 10 to accept the
appropriate values. Find and print the following with the appropriate messages: ● Sum of
the ASCII of all upper case letters ● Count of digits

Question 4 [10] Define a class to declare an array of double data type to store the monthly
salary of twenty employees of “TechTune Ltd.” company. Find and print the annual
amount spent by the company on the salaries of their employees. Also print the number
of employees earning more than Rs. 80,000.00 per month. Print the output with the
appropriate messages. 3

Question 5 [10] Define a class to accept two strings and check whether the larger string is
ending with the smaller string or not. Print the strings with the appropriate message. If
both the strings are equal in length, print the message “Invalid input, re-enter”.

Question 6 [10] Define a class to accept a string. Convert the string to upper case. Count
and print the number of double letter sequences that exist in the string. Sample input:
THE LITTLE RABBIT IS EATING AN APPLE Sample output: 3

Question 7 [10] Define a class to accept ten words in an array declared as String. Accept
a letter from the user and convert it to uppercase. To print the number of words which
end with this letter, convert each word of the array to uppercase before checking. Print
the number with the appropriate message. ______________________________________

Question 3 Write a program to accept 10 random integer data each into two arrays A and
B. Create a third array C. In each location of array C, store the greater of the two data
from the corresponding locations of array A and B. Display the three arrays vertically with
an appropriate heading. [10] 2

Question 4 Write a program in Java to accept a string. Convert the string to lowercase
and change the first letter of every word to uppercase. Also count how many of the words
begin with the letter ‘A’. Display the lowercase string and the new string and the count of
words beginning with the letter ‘A’ with appropriate messages. Sample input: The boy
bought an apple and a banana to eat Sample output: Original String : the boy bought an
apple and a banana to eat Converted String : The Boy Bought An Apple And A Banana To
Eat No. of words beginning with ‘A’ : 4

You might also like