Java program to Find Factorial of Given no.

Friday, February 4th, 2011  »  Posted By surajk  »  Total 0 Comment

1 2 3 4 5 6 7 8 9 10 11 class Factorial{ public static void main(String args[]){ int num = Integer.parseInt(args[0]); //take argument as command line int result = 1; while(num>0){ result = result * num; num–; } System.out.println("Factorial of Given no. is : "+result); } }

Java program to find SUM AND PRODUCT of a given Digit.

Friday, February 4th, 2011  »  Posted By surajk  »  Total 0 Comment

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 class Sum_Product_ofDigit{ public static void main(String args[]){ int num = Integer.parseInt(args[0]); //taking value as command line argument. int temp = num,result=0; //Logic for sum of digit while(temp>0){ result = result + temp; temp–; } [...]

Java program to display a greet message according to student marks

Friday, February 4th, 2011  »  Posted By surajk  »  Total 0 Comment

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 /* Write a program to display a greet message according to Marks obtained by student. */ class [...]

Java program to generate 5 Random nos. between 1 to 100

Friday, February 4th, 2011  »  Posted By surajk  »  Total 0 Comment

1 2 3 4 5 6 7 8 9 10 /*Write a program to generate 5 Random nos. between 1 to 100, and it should not follow with decimal point. */ class RandomDemo{ public static void main(String args[]){ for(int i=1;i<=5;i++){ System.out.println((int)(Math.random()*100)); } } }

Java program to print Small Integer, Largest Integer

Friday, February 4th, 2011  »  Posted By surajk  »  Total 0 Comment

1 2 3 4 5 6 7 8 9 10 11 12 13 14 /* Write a program that will read a float type value from the keyboard and print the following output. ->Small Integer not less than the number. ->Given Number. ->Largest Integer not greater than the number. */ class ValueFormat{ public static void [...]

Java program to find Minimum of 2 nos. using conditional operator

Friday, February 4th, 2011  »  Posted By surajk  »  Total 0 Comment

1 2 3 4 5 6 7 8 9 10 class Minof2{ public static void main(String args[]){ //taking value as command line argument. //Converting String format to Integer value int i = Integer.parseInt(args[0]); int j = Integer.parseInt(args[1]); int result = (i<j)?i:j; System.out.println(result+" is a minimum value"); } }

Java program to find Maximum of 2 nos

Friday, February 4th, 2011  »  Posted By surajk  »  Total 0 Comment

1 2 3 4 5 6 7 8 9 10 11 12 class Maxof2{ public static void main(String args[]){ //taking value as command line argument. //Converting String format to Integer value int i = Integer.parseInt(args[0]); int j = Integer.parseInt(args[1]); if(i > j) System.out.println(i+" is greater than "+j); else System.out.println(j+" is greater than "+i); } }

java program for Client-Server Program using TCP/IP

Wednesday, February 2nd, 2011  »  Posted By Ranjith  »  Total 0 Comment

Program : Client-Server Program using TCP/IP By : Kapil Lohia import java.net.*; import java.io.*;   class tcpip_server { public static void main(String args[]) throws IOException { ServerSocket n1=null; try { n1=new ServerSocket(98); } catch(IOException e) { System.err.println("Port 98 could not be found"); System.exit(1); } Socket c=null; try { c=n1.accept(); System.out.println("Connection from "+c); } catch(IOException e) [...]

Java program to display Domain name service (DNS)

Friday, April 30th, 2010  »  Posted By Ranjith  »  Total 0 Comment

Program : Domain name service (DNS) By : Kapil Lohia   import java.net.*;   class dns { public static void main(String args[]) throws Exception { try { InetAddress[] address=InetAddress.getAllByName("java.sun.com"); for(int j=0;j<address.length;j++) System.out.println(address[j]); }   catch(Exception e) { System.out.println("Error in accessing Internet :"+e); } } }

Java program to display the IP Address of a particular Host

Friday, April 30th, 2010  »  Posted By Ranjith  »  Total 0 Comment

Program : To display the IP Address of a particular Host By : Kapil Lohia import java.net.*; import java.io.*;   public class ip_host { public static void main(String args[]) throws Exception { System.out.println("Enter the host name :"); String n=new DataInputStream(System.in).readLine();   InetAddress ipadd =InetAddress.getByName(n);   System.out.println("IP address :"+ipadd); } }

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup