[login to view URL]

Completed Posted Feb 25, 2012 Paid on delivery
Completed Paid on delivery

I need to rewrite the attached java file so that the size of the array is specified by the first command-line argument. If no command-line argument is supplied or entered, use 10 as the default size of the array. Use a two or three arguments at most.

The final program will look akin to this:

// Initializing an array using command-line arguments.

public class InitArray

{

public static void main( String[] args )

{

// check number of command-line arguments

if ( [url removed, login to view] != 3 )

[url removed, login to view](

"Error: Please re-enter the entire command, including\n" +

"an array size, initial value and increment." );

else

{

// get array size from first command-line argument

int arrayLength = [url removed, login to view]( args[ 0 ] );

int[] array = new int[ arrayLength ]; // create array

// get initial value and increment from command-line arguments

int initialValue = [url removed, login to view]( args[ 1 ] );

int increment = [url removed, login to view]( args[ 2 ] );

// calculate value for each array element

for ( int counter = 0; counter < [url removed, login to view]; counter++ )

array[ counter ] = initialValue + increment * counter;

[url removed, login to view]( "%s%8s\n", "Index", "Value" );

// display array index and value

for ( int counter = 0; counter < [url removed, login to view]; counter++ )

[url removed, login to view]( "%5d%8d\n", counter, array[ counter ] );

} // end else

} // end main

} // end class InitArray

But...instead of stating;

"Error: Please re-enter the entire command, including\n" +

"an array size, initial value and increment."

The output will be:

Index Value

0 0

1 0

2 0

3 0

4 0

5 0

6 0

7 0

8 0

9 0

Since default size of array is 10. Otherwise, the size will be whatever is entered on Command_line. For example:

java InitArray 5 0 4

Index Value

0 0

1 4

2 8

3 12

4 16

Must be in Java. Not Javascript.

JavaScript PHP

Project ID: #1467369

About the project

6 proposals Remote project Active Feb 25, 2012

Awarded to:

freelancer4142

hi, I read your complete statement and completely understand your requirements. I can complete this task within 1 hour. Ready to start. Waiting for a positive response. Thank you.

$30 USD in 1 day
(6 Reviews)
2.4

6 freelancers are bidding on average $30 for this job

dobreiiita

Hi, I can surely handle this project. Thanks

$30 USD in 1 day
(27 Reviews)
4.5
manhpham

I am ready to do with 20$ only.

$30 USD in 1 day
(13 Reviews)
4.1
chSoft

Let me fix it.

$30 USD in 0 days
(1 Review)
1.8
MuhammadEzzeldin

Dear sir , i am a developer and an information systems graduate . i can do the job less than 2 hrs or less . kindly check your PMB

$30 USD in 0 days
(3 Reviews)
1.2
SMISHRA

Hi, Please give a chance to serve you. Thanks & Regards, SMISHRA

$30 USD in 0 days
(0 Reviews)
0.0