Trending ▼   ResFinder  

ICSE Notes of all important string programs 2018 : Computer Applications (St. Francis School (SFS), Madhurawada, Visakhapatnam)

7 pages, 19 questions, 1 questions with responses, 1 total responses,    2    0
Deekshitha Alla
St. Francis School (SFS), Madhurawada, Visakhapatnam
7 to 10
+Fave Message
 Home > alladee3 >   F Also featured on: School Page rikhil32

Formatting page ...

//P1 to add a string to a character import java.io.*; public class stringPlusChar { void methods()throws IOException { InputStreamReader ir = new InputStreamReader(System.in);; BufferedReader br = new BufferedReader(ir); System.out.println("please enter a word"); String str = br.readLine(); char ch = str.charAt(3); System.out.println("werwerw"+ ch); } } //P2 to remove all the spaces in a sentence import java.io.*; //importing package public class RemoveSpaces // user defined data type { void method() throws IOException// exception handling { InputStreamReader ir = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ir); System.out.println("please enter a sentance"); String str = br.readLine(); String str2 = str.replace(" ",""); System.out.println(str2); } } //P3 to print the consecutive repeated characters in a sentence import java.io.*; public class repeated { void method()throws IOException { String str1 = " "; InputStreamReader ir = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ir); System.out.println("Please eneter a sentance"); String str = br.readLine(); str1 = str.replace(" ",""); int n = str1.length(); System.out.println("The repeated characters are"); for(int i=0; i<n-1; i++) { if(str1.charAt(i)==str1.charAt(i+1)) System.out.print(str1.charAt(i)+" "); } } } //P4 to count the small letters, capital letters and blank spaces import java.io.*; public class Charcount { int c,s,b; void method()throws IOException { InputStreamReader ir = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ir); System.out.println("please enter a sentance"); String str = br.readLine(); str.trim(); int n = str.length(); for(int i=0; i<n; i++) { char ch = str.charAt(i); if(Character.isLowerCase(ch)) s++; else if(Character.isUpperCase(ch)) c++; else if(Character.isWhitespace(ch)) b++; } System.out.println("The number of small letters are "+s); System.out.println("The number of capital letters are "+c); System.out.println("The number of blank spaces are "+b); } } // P5 to print all the first characters of the sentence import java.io.*; public class firstCharacters { void method()throws IOException { InputStreamReader ir = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ir); System.out.println("please enter a sentance"); String str = br.readLine(); int len = str.length(); System.out.println(str.charAt(0)); for(int i=1; i<len; i++) { char ch = str.charAt(i); if(ch==' ') System.out.println(str.charAt(i+1)); } } } //P6 to count the number of words in the sentence import java.io.*; public class NoofWords { void method()throws IOException { int count=0; InputStreamReader ir = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ir); System.out.println("please enter a sentance"); String str = br.readLine(); str = str+" "; int n = str.length(); for(int i=0; i<n; i++) { if(str.charAt(i)==' ') count++; } System.out.println("the number of words are"+count); } } //P7 to print all the words separately import java.io.*; // importing a package public class wordsprint // user defined data type { void method()throws IOException // exception handling { int count=0,m=0; //local variables InputStreamReader ir = new InputStreamReader(System.in); //call by reference BufferedReader br = new BufferedReader(ir); System.out.println("please enter a sentance"); String str = br.readLine();//non static method of string class str = str+" "; int n = str.length(); for(int i=0; i<n; i++) { if(str.charAt(i)==' ') {System.out.println(str.substring(m,i)); m=i+1; } } } } //P8 print the count of each word in a sentence import java.io.*; public class wordcount { int m=-1,next,n; void method()throws IOException { String sent = " "; String wd = " "; InputStreamReader ir = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ir); System.out.println("Please enter a sentance"); String str = br.readLine(); str= str+" "; int len = str.length(); for(int i=0;i<len; i++) { char ch = str.charAt(i); if(ch==' ') { next = i; wd = str.substring(m+1,next); n = wd.length(); m=next; System.out.println(wd+"------"+n); } } }} //P9 pattern1 public class pattern { { int i,j,n=5; void method() for(i=0;i<=n;i++) { System.out.println(); for(j=1;j<=n-i;j++) System.out.print(j); for(j=0;j<2*i;j++) System.out.print(" "); for(j=n-i;j>0;j--) System.out.print(j); }}} //P10 pattern 2 public class pat2 { void method() { int i,j,n=5; for(i=1; i<=n ;i++) { for(j=1; j<=i; j++) System.out.print(j); for(int k = i*2; k<n*2; k+ +) System.out.print(" "); for(int m=i; m>=1; m--) System.out.print(m); System.out.println(); } } } //P11 pattern 3 public class PatternSubstring { void method() { String str = "bluej"; int len = str.length(); for(int i=len; i>0; i--) System.out.println(str.subst ring(i,0)); }} //P12 surname import java.io.*; public class surname { void method()throws IOException { String st1 = " ", st2 = " "; InputStreamReader ir = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ir); System.out.println("please enter a name with FN MN and LN"); String str = br.readLine(); str = " "+str; int p = str.lastIndexOf(' '); st2 = str.substring(p); for(int i=0;i<p; i++) { char ch = str.charAt(i); if(ch==' ') st1 = st1+str.charAt(i+1)+"."; } st2= st1+ st2; System.out.println("are you searching"+ st2); }} //P13 given word in dictionary order import java.io.*; public class dictionary { void method()throws IOException { InputStreamReader ir = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ir); System.out.println("please enter a word"); String str= br.readLine(); int len = str.length(); for(int i=65; i<=90; i++) { for(int j=0; j<len; j++) { char ch =str.charAt(j); if(ch==(char)i||ch==(char)(i+32)) System.out.print(ch); } }}} //P14 reversing the given sentence import java.io.*; public class sentrev { void method()throws IOException { String wd = " "; String sent = " "; InputStreamReader ir = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ir); System.out.println("please enter a sentance"); String str = br.readLine(); str= str+" "; int len = str.length(); for(int i=0; i<len; i++) { char ch= str.charAt(i); if(ch!=' ') wd = ch+wd; else { sent = wd+sent; wd = " "; } } System.out.println(sent); }} //P15 longest word in the sentence import java.io.*; public class LongestWord { String wd =" "; int n; void method()throws IOException { InputStreamReader ir = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ir); String longwd = " "; int longest = 0; int m = 0; System.out.println("Please enter a sentane"); String sent = br.readLine(); sent = sent+" "; int len =sent.length(); System.out.println("The words of the sentance are "); for(int i=0; i<len; i++) { if(sent.charAt(i)==' ') { String wd = sent.substring(m,i); System.out.println(wd); n = wd.length(); if(n>longest) { longest = n; longwd = wd; } m=i+1; } } System.out.println("the longest word "+ longwd + " has "+ longest + " characters"); //P16 sentence with words in alphabetic order import java.io.*; public class WordsOfSentanceInOrder { String wd =" "; int n; String nwd = " ", nsent =" "; void method()throws IOException { InputStreamReader ir = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ir); String longwd = " "; int longest = 0; int m = 0; System.out.println("Please enter a sentane"); String sent = br.readLine(); sent = sent+" "; int len =sent.length(); for(int i=0; i<len; i++) { }} if(sent.charAt(i)==' ') { String wd = sent.substring(m,i); n = wd.length(); for(int p = 65; p<=90; p++) { for(int j = 0; j<n; j++) { char ch = wd.charAt(j); if(ch==(char)p||ch==(char)p+32) nwd = nwd+ch; } } System.out.print(nwd + " "); m=i+1; wd = " "; nwd = " "; } } System.out.println(nsent); } }

Formatting page ...

Top Contributors
to this ResPaper
(answers/comments)


ResPaper Admins

(1)

Ansh Anand

(1)

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

 

  Print intermediate debugging step

Show debugging info


 

 

© 2010 - 2025 ResPaper. Terms of ServiceContact Us Advertise with us

 

alladee3 chat