[login to view URL]
$30-250 USD
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.
Project ID: #1467369
About the project
Awarded to:
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.
6 freelancers are bidding on average $30 for this job
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