Saturday, 13 February 2016

tybca slip85

import java.io.*;

import java.net.*;



  class slip85server
 {

  ServerSocket sob;
 
  Socket cob;

 DataInputStream dis;

 DataOutputStream dos;

 OutputStream os;

 InputStream is;


    slip85server()
 {


  try
 {


   sob=new ServerSocket(1300);


  System.out.print("\n Server is Started....");

  cob=sob.accept();


 System.out.print("\n Client is Connected...");


  is=cob.getInputStream();
  os=cob.getOutputStream();


   dis=new DataInputStream(is);


   dos=new DataOutputStream(os);

  }

 catch(Exception e)
 {

 System.out.print(e.getMessage());

  }

}



  void sent()
 {

   try
 {


     String str=dis.readUTF();


     int n=Integer.parseInt(str);


System.out.print("\n \n Given Number is="+n);




        if(!Character.isDigit(n)) //isDigit() return a false when condition is true
         {

           int fact=1;
  
            for(int i=1;i<=n;i++)
            {


        fact=fact*i;


        }


         dos.writeUTF("\n \n Factorial is="+Integer.toString(fact));


          }
         else
       {



         dos.writeUTF("It is  not a number");



        }

   }

 catch(Exception e)
 {

  System.out.print(e.getMessage());

 }

 }



public static void main(String ars[])
 {

 slip85server ob=new slip85server();

 ob.sent();

 }
}





  

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.

 
Copyright © 2013. BloggerSpice.com - All Rights Reserved
Author: MohammadFazle Rabbi | Powered by: Blogger
Designed by: Blogger Spice
^