Class Sentence - ICSE - PROJECT

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Class Sentence - ICSE_PROJECT 1/1

1 import java.util.*;
2 class Sentence
3 {
4 public static void main(String args[])/**main function definition*
/
5 {
6 String s,s2="",d="",s3="";/**variable declaration and initiali
zation*/
7 Scanner sc=new Scanner(System.in);
8 System.out.println("Enter a sentence");
9 s=sc.nextLine();
10 int i,t1=0,t=0,l=s.length();
11 char c,c2;
12 s=s.toUpperCase();
13 for(i=0;i<l;i++)
14 { c=s.charAt(i);
15 if(i<l-1){
16 c2=s.charAt(i+1);
17 if(c==c2)
18 {
19 d+=""+c+c2+" ";/**concatenation*/
20 t++;/**counter value increment by 1*/
21 }
22 }
23 if("AEIOUaeiou".indexOf(c)>=0)/**vowel checking*/
24 { s2+='*';/**forward concatenation*/
25 s3+=c;/**forward concatenation*/
26 t1++;/**counter value increment by 1*/
27 }else
28 s2+=c;/**forward concatenation*/
29 }
30 System.out.println(s+"\nDouble letters:"+d+" Total="+t+"\nVowe
ls:"+s3+" Total="+t1+"\nAfter replacing all the vowels by *(asterisk)
symbol of the sentence:\n"+s2);/**displaying the message*/
31 }/**end of main()*/
32 }/**end of class Sentence*/
33

21 Nov, 2017 9:47:42 PM

You might also like