Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Socket;
- import java.io.IOException;
- import java.io.PrintStream;
- import java.net.ServerSocket;
- import java.net.Socket;
- import java.util.Scanner;
- public class Server {
- public static void main(String[] args) throws IOException {
- int number;
- ServerSocket server = new ServerSocket(1211);
- Socket socket = server.accept();
- Scanner scan = new Scanner(socket.getInputStream());
- number = scan.nextInt();
- PrintStream printout = new PrintStream(socket.getOutputStream());
- if(number > 0){
- printout.println("The number is positive.");
- if ((number % 2) == 0) {
- printout.println("It also is an even one.");
- if(number%5 == 0)
- printout.println("As well as it can be divided by 5.");
- } else {
- if(number%5 == 0)
- printout.println("As well as it can be divided by 5.");
- printout.println("It also is an odd one.");
- }
- }
- else{
- printout.println("The number is negative.");
- if ((number % 2) == 0) {
- printout.println("It also is an even one.");
- if(number%5 == 0)
- printout.println("As well as it can be divided by 5");
- }
- else{
- printout.println("It also is an odd one.");
- if(number%5 == 0)
- printout.println("As well as it can be divided by 5");
- }
- }
- server.close();
- scan.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement