Skipping Through Arrays Tutorial

From Progzoo
Jump to: navigation, search

In these questions you must complete the method doStuff.

The system will call your method three times with a different array each time.

Your method should give the output specified each time.

Only Even Indexes

Print every other element

Print element 0, element 2, 4 etc.

For the list 8,7,9,7,4,6
you must print
8
9
4


[Font] [Default] [Show] [Resize] [History] [Profile]

Add consecutive pairs

Print element 0 add element 1, 2 add 3, 4 add 5

For the array [2, 7, 5, 3] you should print 9 and 8 (that is 2+7 and 5+3).


[Font] [Default] [Show] [Resize] [History] [Profile]

Print Consecutive Pairs

Print element 0 and element 1 on the first line, print 2 and 3 on the second...

For the array [2, 7, 5, 3] you should print:

2 7
5 3


[Font] [Default] [Show] [Resize] [History] [Profile]

Print Columns

Print the numbers in two columns

For the array [2, 7, 5, 3, 5, 6] you should print:

2 3
7 5
5 6


[Font] [Default] [Show] [Resize] [History] [Profile]