Page 3 :
import java.util.*;, class count, {, int l,i,cap=0,sm=0,d=0,sp=0;char c;String s;, void main(), {, Scanner sc=new Scanner(System.in);, System.out.println("Enter a string");, s=sc.nextLine();, l=s.length();, for(i=0;i<l;i++), {, c=s.charAt(i);, if(Character.isUpperCase(c)), // (c>='A' && c<='Z'), cap++;, else if(Character.isLowerCase(c)) //(c>='a' && c<='z'), sm++;, else if(Character.isDigit(c)) //(c>='0' && c<='9'), d++;, else, sp++;, }, System.out.println("Capital letters="+cap);, System.out.println("Small letters="+sm);, System.out.println("Digits="+d);, System.out.println("Special characters="+sp);, }, }, , Input a word in uppercase and check for the position, of the first occurring vowel and perform the, following operation., , (i) Words that begin with a vowel are concatenated, with “Y”., For example, EUROPE becomes EUROPEY., (ii) Words that contain a vowel in-between should, have the first part from the position of the vowel till, the end, followed by the part of the string from, beginning till the position of the vowel and is, concatenated by “C”. For example, PROJECT, becomes OJECTPRC., (iii) Words which do not contain a vowel are, concatenated with “N”. For example, SKY becomes, SKYN., , COMBINED ICSE 246 Page 3
Page 6 :
class PALIN, {, int l,i;, String w="",str="",rev="";, char c,c1;, void main(String s), {, s=s+" ";, l=s.length();, for(i=0;i<l;i++), {, c=s.charAt(i);, if(c!=' '), w=w+c;, else, {, c1=w.charAt(0);, str=str+c1;, rev=c1+rev;, w="";, }, }, if(str.equalsIgnoreCase(rev)), System.out.println("Palindrome String");, else, System.out.println("not Palindrome String");, }, }, , A class Rearrange has been defined to modify a word by bringing all the vowels in the word at the beginning, followed by the consonants. [10], Example: ORIGINAL becomes OIIARGNL, , Design a class Exchange to accept a word and interchange the first, alphabet with the last alphabet, with single-letter, word remaining unchanged., , COMBINED ICSE 246 Page 6
Page 7 :
class interchange, {, void main(String s), {, int l=s.length();, if(l==1), System.out.println(s);, else, System.out.println(s.charAt(l-1)+s.substring(1,l-1)+s.charAt(0));, }, }, A sequence of Fibonacci strings is generated as follows:, S1 = “a”,, S2 = “b”,, Sn = S(n-1) + S(n-2), where „+‟ denotes concatenation. Thus the sequence is:, a, b, ba, bab, babba, babbabab,……. n terms., class fibo, {, int i;String x,y,z;, void main(int n), {, x="a";, y="b";, System.out.print(x+" "+y);, for(i=1;i<=n-2;i++), {, z=y+x;, System.out.print(" "+z);, x=y;, y=z;, }, }, }, Write a program in Java to accept a word/a String and display the new string after removing all the vowels, present in it., Sample Input:, COMPUTER APPLICATIONS, Sample Output:, CMPTR PPLCTNS, , class remove, {, int l,i;char c;String newstr="";, void main(String s), {, l=s.length();, for(i=0;i<l;i++), {, c=s.charAt(i);, if(c!='A'&&c!='E'&&c!='I'&&c!='O'&&c!='U'), newstr=newstr+c;, }, System.out.print(newstr);, }, }, , COMBINED ICSE 246 Page 7
Page 8 :
Write a program in Java to enter a String/Sentence and display the longest word and the length of the longest word, present in the String., Sample Input: “TATA FOOTBALL ACADEMY WILL PLAY AGAINST MOHAN BAGAN”, Sample Output: The longest word: FOOTBALL: The length of the word: 8, , class longest, {, int l,i,len;char c;String w="",large;, void main(String s), {, large="";, len=0;, s=s+" ";, l=s.length();, for(i=0;i<l;i++), {, c=s.charAt(i);, if(c!=' '), w=w+c;, else, {, if(w.length()>large.length()), {, large=w;, len=w.length();, }, w="";, }, }, System.out.print("largest word is "+large+" and its length is "+len);, }, }, , class longest, {, int l,i,len;char c;String w="",small;, void main(String s), {, small=s;, len=0;, s=s+" ";, l=s.length();, for(i=0;i<l;i++), {, c=s.charAt(i);, if(c!=' '), w=w+c;, , COMBINED ICSE 246 Page 8
Page 9 :
if(c!=' '), w=w+c;, else, {, if(w.length()<small.length()), {, small=w;, len=w.length();, }, w="";, }, }, System.out.print("smallest word is "+small+" and its length is "+len);, , }, }, , COMBINED ICSE 246 Page 9