-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclient.java
More file actions
30 lines (26 loc) · 890 Bytes
/
client.java
File metadata and controls
30 lines (26 loc) · 890 Bytes
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
import java.io.IOException;
import java.io.PrintStream;
import java.net.Socket;
import java.util.Scanner;
public class client {
public static void main(String[] args) throws IOException {
// socket client side
Socket s = new Socket("127.0.0.1",8000);
// input
int number1, number2;
float result;
Scanner sc = new Scanner(System.in); // user input scanner
System.out.println("Enter any Number");
number1 = sc.nextInt();
System.out.println("Enter another Number");
number2 = sc.nextInt();
// stream
PrintStream p = new PrintStream(s.getOutputStream());
p.println(number1);
p.println(number2);
//output
Scanner sc1 = new Scanner(s.getInputStream()); // output scanner output
result = sc1.nextFloat();
System.out.println(result);
}
}