-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSt.java
More file actions
64 lines (60 loc) · 1.56 KB
/
Copy pathSt.java
File metadata and controls
64 lines (60 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import java.io.*;
class St
{
String s,s1;
int v,c;
St()
{
s=s1="";
}
void input()throws IOException
{
BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the sentence in given format");
s=sc.readLine().toLowerCase();
if(s.charAt(s.length()-1)!='.')
if(s.charAt(s.length()-1)!='?')
{
System.out.println("Invalid Input");
System.exit(0);
}
}
String cap(String a)
{
char c[]=a.toCharArray(),t;
t=c[0];
c[0]=Character.toUpperCase(t);
a="";
for(int i=0;i<c.length;i++)
a+=c[i];
return a;
}
void display()
{
String p;
int k=0;
System.out.println("Word\t Vowels\t Consonents");
for(int i=0;i<s.length();i++)
{
v=c=0;
if(s.charAt(i)==' '||s.charAt(i)=='.'||s.charAt(i)=='?')
{
p=s.substring(k,i);
k=i+1;
s1+=cap(p)+s.charAt(i);
for(int j=0;j<p.length();j++)
if(p.charAt(j)=='e'||p.charAt(j)=='u'||p.charAt(j)=='o'||p.charAt(j)=='i'||p.charAt(j)=='a')
v++;
c=p.length()-v;
System.out.println(cap(p)+"\t\t"+v+"\t "+c);
}
}
System.out.println(s1);
}
public static void main()throws IOException
{
St ob=new St();
ob.input();
ob.display();
}
}