java-exercises-2
java-exercises-2
1. Write tester class, Program1 to read a sentence in string variable and convert
the first letter
of each word to capital case. Print the final string.
Note: - Only the first letter in each word should be in capital case in final
string.
Write a static method getCapitalized which accepts a string. The return type
(String) should
return the capitalized string.
Sample Input:
Now is the time to act!
Sample Output:
Now Is The Time To Act!
2.Write tester class, Program2 to read an integer array and find the index of
larger
number of the two adjacent numbers with largest difference. Print the index.
Write a static method findMaxDistance which accepts an integer array and the number
of elements in the array.
The return type (Integer) should return index.
4
8
6
1
9
4
Sample Output :
4
3. Write tester class, Program3 to read a string and validate PAN number against
following
rules:
1. There must be eight characters.
2. First three letters must be alphabets followed by four digit number and ends
with alphabet
3. All alphabets should be in capital case.
4.Write a tester class, Program4 to read a string and a character, and reverse
the string and convert it in a format such that each character is separated by the
given character. Print the final string.
Write a static method reshape() which accepts a string and a character.
The return type (String) should return the final string.
Sample Input:
Rabbit
-
Sample Output:
t-i-b-b-a-R
Write a static method getLastLetter() which accepts a string. The return type
(string)
should return the final string.
Sample Input:
555-666-1234
Sample Output:
55-56-661-234