-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRearrange1.java
More file actions
61 lines (56 loc) · 1.33 KB
/
Copy pathRearrange1.java
File metadata and controls
61 lines (56 loc) · 1.33 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
import java.io.*;
public class Rearrange1
{
String wrd,newwrd;
Rearrange1()
{
wrd="";
newwrd="";
}
void readword()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the word in Upper case");
wrd=br.readLine();
}
void freq_vow_con()
{
int v=0,c=0;
for(int i=0;i<wrd.length();i++)
{
char ch=wrd.charAt(i);
if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
v++;
else
c++;
}
System.out.println("Frequency of Vowels="+v);
System.out.println("Frequency of Consonents="+c);
}
void arrange()
{
String a="",b="";
for(int i=0;i<wrd.length();i++)
{
char ch=wrd.charAt(i);
if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
a+=ch;
else
b+=ch;
}
newwrd+=a+b;
}
void display()
{
System.out.println("Original Word="+wrd);
System.out.println("Rearranged Word="+newwrd);
}
public static void main()throws IOException
{
Rearrange1 ob=new Rearrange1();
ob.readword();
ob.freq_vow_con();
ob.arrange();
ob.display();
}
}