Write a program to check if the word 'orange' is present in the "This is orange juice".
6.
Write a program to find the first and the last occurence of the letter 'o' and character ',' in "Hello, World".
For first occurance, iterate from beginning and for last ocurrance, iterate from last.
7.
Write a program that takes your full name as input and displays the abbreviations of the first and middle names except the last name which is displayed as it is. For example, if your name is Robert Brett Roser, then the output should be R.B.Roser.
importjava.util.*;classAns{publicstaticvoidmain(String[]args){Scanners=newScanner(System.in);Stringst=s.nextLine();Stringsr="";sr=sr+st.charAt(0);sr=sr+". ";for(inti=0;i<st.length();i++){if(st.charAt(i)==' '&&st.charAt(i+1)!=' '&&i+1<st.length()){sr=(sr+st.charAt(i+1)).toUpperCase();sr=sr+". ";}}Stringlast_wrd="";//to get the last wordfor(inti=st.length()-1;i>=0;i--){if(st.charAt(i)==' '){last_wrd=st.substring(i+2);break;}}//to remove last ". "sr=sr.substring(0,sr.length()-2);sr=sr+last_wrd;System.out.println(sr);}}
8.
Write a program to find the number of vowels, consonents, digits and white space characters in a string.
9.
Write a program to delete all consonents from the string "Hello, have a good day".
10.
Input a string of alphabets. Find out the number of occurrence of all
alphabets in that string. Find out the alphabet with maximum occurrence.
You can use an array of length 26 to store the number of occurance of each character in the elements of the array.
Level 2
1.
Write a program to check if a given string is a Palindrome. A palindrome reads same from front and back e.g.- aba, ccaacc, mom, etc.
Write a program to check if the two strings entered by user are anagrams or not. Two words are said to be anagrams if the letters of one word can be rearranged to form the other word. For example, jaxa and ajax are anagrams of each other.
5.
Input a string which contains some palindrome substrings. Find out the
position of palindrome substrings if exist and replace it by *. (For example if
input string is “bob has a radar plane” then it should convert in “*** has a
***** plane”.
Write a program to replace a given substring in a sentence with another string. For
example, in the sentence, ” A batman with bat” if we replace ”bat” with ”snow”, the
new sentence should be printed as ”A snowman with snow”.
7.
Write a program to reverse individual words in a string, where each word may be delimited by a dot, comma, space or tab, like www.google.com should become www.elgoog.moc.