package en.codegym.task.pro.task05.task0502;
/*
Even and odd cells of an array
*/
public class Solution {
public static final String ODD = "Odd";
public static final String EVEN = "Even";
public static String[] strings = new String[5];
public static void main(String[] args) {
//write your code here
for(int i = 0; i < strings.length; i++){
if(i%2 ==0) {
strings[i] = EVEN;
}else{
strings[i] =ODD;
}
}
System.out.print("index = 0");
System.out.println(" value = " + strings[0]);
System.out.print("index = 1");
System.out.println(" value = " + strings[1]);
System.out.print("index = 2");
System.out.println(" value = " + strings[2]);
System.out.print("index = 3");
System.out.println(" value = " + strings[3]);
System.out.print("index = 4");
System.out.println(" value = " + strings[4]);
}
}
answer
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Pritish Kanti Datta
29 December 2022, 16:40
value : EVEN
value : ODD
value : EVEN
value : ODD
value : EVEN
+2