Very Basic Query on Java Array processing -
trying self teach java here, complete beginner.
im trying select , print multiples of 10 array.
its surely simple if know how?
thanks can give....!
on side note think glass of whiskey might necessary me through learning this??
my (very dodgy) code is:
//print multiples of 10 in array double dangermouse[] = { 1,2,4,8,16,32,64,128,256,512 }; double total = 0; if (total %10 = 0) { (double x : dangermouse) { total = x; } } system.out.println (total);
dangermouse
you should stop drinking whisky while coding.
for (int = 0; < dangermouse.length; i++) { if (dangermouse[i] % 10 == 0) { system.out.println(dangermouse[i]); } }
loop goes through array. if statement checks current array member if multiple of 10. if print , move next element in array , repeat until run out of array.
Comments
Post a Comment