Bookmark and Share

Tuesday, June 2, 2009

Taking the size of an Array at runtime & generate random numbers to populate the Array


//Author     : Ganesh Iyer, Mobile (0)9176148207

//Program : Taking the size of an Array at runtime & generate random numbers to populate the Array
//Written on : 29th May 2009


//Include java packages

import java.io.*;
import java.lang.*;
import java.util.*;

class generateRan
{

public static void main(String[] args)

{

int buffer, cnt;

try { // To catch error


//One of the method provided by JAVA in taking input from the screen


BufferedReader r = new BufferedReader(new InputStreamReader(System.in));

System.out.println(\"Input the Array length in [0-9]\");


//Casting string to Integer

buffer = Integer.parseInt(r.readLine());


//Check for zero & negative input through screen

if (buffer==0 || buffer<0) mx =" new" cnt="0;">

No comments:

More Magazines