.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Code Snippets >> OOPS >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Using java package Select the random number between source to destination

Posted By:laptop charles       Posted Date: June 30, 2010    Points: 10    Category: OOPS    URL: http://www.dotnetspark.com  

Select the random number.

It contain to get two number.
It is like Source and destination.
Using user defined package.
The following coding inside the folder.
package rand;
import java.io.*;

public class cpack
      public String read()throws IOException
           BufferedReader br=new  BufferedReader(new InputStreamReader(System.in));
         String str=br.readLine();
        return str;

public void paste(String st)
The following code is outside the folder.
import rand.*;
import java.io.*;
class pk2
      public static void main(String ar[])throws IOException
          cpack c=new cpack();
          int a[]=new int[100];

          c.paste("Enter the how many value");
          int n=Integer.parseInt(c.read());
              for(int i=1;i<=n;i++)
                 c.paste("Enter the "+i+" Element");
          c.paste("Enter source ");
          int so=Integer.parseInt(c.read());   
          c.paste("Enter destination ");
          int de=Integer.parseInt(c.read());   
              for(int i=so;i<=de;i++)
                 c.paste("The "+i+" Element is");


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend