Devam Ediyor

[url removed, login to view]

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.

Beceriler: Javascript, PHP

Daha fazlasını görün: rewrite size array specified command line argument, initarray java, new in java 1.5, javascript look for a string in a string, java 1.5 for each, int size c, get length of string in c, get arguments javascript, element 8, rewrite initarray size array specified command line argument, get java, VOID, java file, akin, php javascript class, java calculate, display counter php, using program java, display string file java, java display file, string integer, file system java, java using system, java initial, java output file

İşveren Hakkında:
( 11 değerlendirme ) Toledo, United States

Proje NO: #1467369

Seçilen:

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.

1 gün içinde 30$ USD
(6 Değerlendirme)
2.4

6 freelancers are bidding on average $30 for this job

dobreiiita

Hi, I can surely handle this project. Thanks

1 gün içinde 30$ USD
(27 Değerlendirme)
4.5
manhpham

I am ready to do with 20$ only.

1 gün içinde 30$ USD
(13 Değerlendirme)
4.1
chSoft

Let me fix it.

in 0 gün içinde30$ USD
(1 Değerlendirme)
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

in 0 gün içinde30$ USD
(3 Değerlendirme)
1.2
SMISHRA

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

in 0 gün içinde30$ USD
(0 Değerlendirme)
0.0