String XII Isc by Prateik Sharma
String XII Isc by Prateik Sharma
1. Write a program in Java to accept a character from the user display whether it is a upper case
character or lower case characters or digit or blank space or special character.
2. Write a program in Java to accept a character from user and convert the uppercase character
to lowercase and display the new character.
3. Write a program in Java to accept a character from user and convert the lower case to upper
case and display the new character.
4. Write a program in Java to accept a string and display each and every character of string in
new line.
5. Write a program in Java to accept a string and display * between each and every character of
string.
6. Write a program in Java to accept a string and display character of string which are present
on even index numbers .
7. Write a program in Java to accept a string and display character of string which are present
on odd index numbers .
8. Write a program in Java to accept a String from the user count and display the number of
upper case character,the number of lower case characters and the number of blank spaces.
9. Write a program in Java to accept a string and display all vowels present in the string.
10. Write a program in Java to accept a string and display * in place of vowels present in the
string.
11. Write a program in Java to accept a string and delete all the vowels present in it.
12. Write a program in java to accept a string and display all UPPERCASE Character present in
the string.
13. Write a program in java to accept a string and display all lowercase Character present in the
string.
14. Write a program in java to accept a string from user and convert the uppercase character
to lowercase and lower case to upper case and display the new string. Example:
INPUT : WelComE TO IMz OUTPUT : wELcOMe to imZ
15. Write a program in Java to accept a string from user and display the new string after
removing all the blank spaces.
e.g : INPUT : My string program OUTPUT : Mystringprogram
16. Write a program in Java to accept a string from user and count the number of times the
given character ‘a’ is present in the string.
17. Write a program in Java to accept a string from user and also accept a character from user
and count the number of times the given character is present in the string.
18. Write a program in Java to accept a string from user and also accept two characters from
user and replace the first character with second character in the string and form a new
string. e.g. INPUT : ABCDABAC Characters A and M OUTPUT : MBCDMBMC
19. Write a program in Java to accept a string and display sum of digits which present in given
string.
SAPMLE INPUT: COM345MTO91QA
SAMPLE OUTPUT: 22
24. Write a program to input a string in uppercase and print the frequency of each character.
Example :
INPUT : ApPLe
OUTPUT : CHARACTERS FREQUENCY
a–1
e– 2
l–1
p–2
25. Write a program to input a string in uppercase and print the frequency of each character.
Example :
INPUT : AapPLeEe
OUTPUT : CHARACTERS FREQUENCY
A–1
a–1
E–1
e–2
L–1
P–1
p–1
Test your program with the sample data and some random data:
Example 1
INPUT : Hello! How are you?
OUTPUT :
The cipher text is:
Uryyb? Ubj ner lbh?
55. Write a program to accept a sentence which may be terminated by either’.’, ‘?’or’!’ only. The
words may be separated by more than one blank space and are in UPPER CASE.
(a) Find the number of words beginning and ending with a vowel.
(b) Place the words which begin and end with a vowel at the beginning, followed by the remaining
words as they occur in the sentence.
Test your program with the sample data and some random data:
Example 1
55. Accept a paragraph of text consisting of sentences that are terminated by either ‘.’ (full stop),
‘!’ (exclamation mark) or a ‘?’ (question mark). Assume that there can be maximum 10 sentences
in a paragraph. Write a program to arrange the sentences in increasing order of their number of
words.
Example:
INPUT : Please come and attend the party. Hello! How are you?
OUTPUT:
Hello=1
A=1
B=2
C=3
.
.
.
Z = 26
The potential of a word is found by adding the encrypted value of the alphabets.
Example: KITE
Potential = 11 + 9 + 20 + 5 = 45
57. Write a program to accept a sentence which may be terminated by either ‘.’ or ‘?’ only. The
words are to be separated by a single blank space. Print an error message if the input does not
terminate with ‘.’ or ‘?’. You can assume that no word in the sentence exceeds 15 characters, so
that you get a proper formatted output.
Example 1
OUTPUT:
Intelligence Plus Character Is Education
Intelligence 5 7
Plus 1 3
Character 3 6
Education 5 4
58. Write a program to accept a sentence which may be terminated by either ‘.’ ‘?’ or ‘!’ only. Any
other character may be ignored. The words may be separated by more than one blank space and
are in UPPER CASE.
(a) Accept the sentence and reduce all the extra blank space between two words to
a single blank space.
(b) Accept a word from the user which is part of the sentence along with its
position number and delete the word and display the sentence.
Test your program with the sample data and some random data:
Example 1
INPUT: A MORNING WALK IS A IS BLESSING FOR THE WHOLE DAY.
WORD TO BE DELETED: IS
WORD POSITION IN THE SENTENCE: 6
59. A sentence in the Special Fashion can be printed by taking two integers (not beyond total
number of words in the sentence or less than 1). These integers tell the word number of the
sentence. Replace only those words present at those given integer places by the next character in
a circular fashion according to the English Alphabets. If both the integers are same then replace
only one word. let us consider the following examples:
(i.e. word number 2 and 4 have been replaced by the next characters in a circular fashion)
60. Write a program to assign a full path and file name as given below. Using library functions,
extract and output the file path, file name and file extension separately as shown.
Input: C:Users\admin\Pictures\flowers.jpg
Output:
Path: C:Users\admin\Pictures
File name: flower
Extension: jpg