-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOperation3.java
More file actions
57 lines (48 loc) · 1.48 KB
/
Operation3.java
File metadata and controls
57 lines (48 loc) · 1.48 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
package com.myfirstjava.program;
import java.net.*;
import java.io.*;
import java.util.*;
// Omer Mohammed Abbas om17102
//om17102@auis.edu.krd
public class Operation3 { // Server 2
public static String txt;
public static void main(String[] args) {
int port = 2131;
try {
ServerSocket serverSocket = new ServerSocket(port);
Socket conn = serverSocket.accept();
InputStream in = conn.getInputStream();
OutputStream out = conn.getOutputStream();
DataInputStream din = new DataInputStream(in);
DataOutputStream dout = new DataOutputStream(out);
BufferedOutputStream bout = new BufferedOutputStream(dout);
do {
int count = 0;
int counter = 0;
txt=din.readUTF();
System.out.println(txt);
txt = txt.toLowerCase();
char[] chars = txt.toCharArray();
for (int i = 0; i <txt.length(); i++) {
if (txt.charAt(i) == 'e') {
count++;
}
}
System.out.println("Total Number of vowels (e): " + count);
dout.writeInt(count);
char ch[] = new char [txt.length()];
for (int i =0; i < txt.length(); i++) {
ch[i]= txt.charAt(i);
if( ((i>0)&&(ch[i]!=' ')&&(ch[i-1]==' ')) || ((ch[0]!=' ')&&(i==0)) ) {
counter++;
}
}
System.out.println("number of words: " + counter);
dout.writeInt(counter);
dout.flush();
}while(true);
}catch (Exception e) {
System.err.println(e.getMessage());
}
}
}