id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

srp4379@lausd.net quiz2 > evenOdd
prev  |  next  |  chance

public int evenOdd(int[] nums).

This problem is meant to determine whether you know the
difference between a POSITION in an array (list) and
the VALUE of a number at that position in the array.

Given an array of integers,
If the numbers at ALL of the even positions are even AND
if the numbers at ALL of the odd positions are odd, return true.

BUT If you find any exceptions to this, that is:
an EVEN number at an ODD position OR
an ODD number at an EVEN position, return false.

NOTE: You have to use an INDEXED For-Loop:

for (int i = 0; i < nums.length; i=i+1) {
       int n = nums[i];
}

"i" refers to the POSITION of an element in the list, and
"nums[i]" refers to the VALUE of the element at position i.


evenOdd([1, 2, 3, 4]) → false
evenOdd([0, 1, 2, 3]) → true
evenOdd([0, 1, 2, 3, 4, 5, 6]) → true

...Save, Compile, Run (ctrl-enter)

public boolean evenOdd(int[] nums){ }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 105

Copyright Nick Parlante 2017 - privacy