Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Simple Java question 3

BunkerHillBroad
BunkerHillBroad 


Suppose that “final” integer SIZE has been properly declared and initialized, and that an array named sample has been declared as follows: int [] sample = new int [SIZE]; Write one or more Java statements to perform the following. Note that each task is independent of the other three: (a) Set all array elements to the value 5. (b) “Swap” the first value in the array with the last value in the array (c) Change any negative values to positive values (with the same magnitude) (d) Print the contents of the “odd-numbered” locations in the array, that is the items at array index 1, 3, 5, ... etc. Attachments
Tags Clarifications

Answers

Simple Java question 3 - Solution

mariobeka
mariobeka 



Open the solution file with any text editor. Attachments Screenshots
Purchase Answer

Problem Solution 3

uetian_cute
uetian_cute 



It contains the answers to all the questions. Attachments
ProblemSolution3.zip (1 K) Download
Preview
i=0;i<sample.length;i++) { sample[i]=5; } /*?Swap? the first value in the array with the last value in the array*/ int temp=sample[0]; sample[0]=sample[sample.length-1]; sample[sample.length-1]=temp; /*Change any negative values to positive values (with the same magnitude)*/ for(int i=0;i<sample.length;i++)

Screenshots
Purchase Answer