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 {
|