-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathalphabet.java
80 lines (80 loc) · 2.01 KB
/
alphabet.java
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import java.util.*;
import java.io.*;
import java.util.Arrays;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
class alphabet extends Thread
{
public void run()
{
try
{
File f1=new File("words.txt");
File fileWrite = new File("output.txt");
FileWriter writer = null;
String[] words=null;
int wc=0;
FileReader fr = new FileReader(f1);
BufferedReader br = new BufferedReader(fr);
String s;
char ch;
int p=0,a=0,r=0,e=0,u=0,v=0,g=0,l=0,m=0,n=0,o=0;
while((s=br.readLine())!=null)
{
int n1=s.length();
for(int i=0;i<n1;i++)
{
ch=s.charAt(i);
if(ch=='p' || ch=='P')
p++;
if(ch=='a'|| ch=='A')
a++;
if(ch=='r'|| ch=='R')
r++;
if(ch=='e'|| ch=='E')
e++;
if(ch=='u'|| ch=='U')
u++;
if(ch=='v'|| ch=='V')
v++;
if(ch=='g'|| ch=='G')
g++;
if(ch=='l'|| ch=='L')
l++;
if(ch=='m'|| ch=='M')
m++;
if(ch=='n'|| ch=='N')
n++;
if(ch=='o'|| ch=='O')
o++;
}
}
fr.close();
fileWrite.createNewFile();
writer = new FileWriter(fileWrite);
writer.write("p="+p+" a="+a+" r="+r+" e="+e+" u="+u+" v="+v);
writer.write("\n");
writer.write("g="+g+" l="+l+" m="+m+" n="+n+" o="+o);
writer.flush();
writer.close();
System.out.println("Your Program is Compiled Successfully\n Show your output in output.txt");
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
class Ass_09_1
{
public static void main(String arg[])
{
new alphabet().start();
}
}