Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

we use java script for this problem it is a programming class F12 on var arrayIn

ID: 3714778 • Letter: W

Question

we use java script for this problem it is a programming class

F12 on var arrayInventory 119, 94, 92, 33, ory 1202, 110, 58., R5, 217, 223, 34, 102, 220,9,199, 137, 171, 109, 167. 53 118, 132, 192, 15, 77,248, 25, 166, 44, 24, 112, 43, 172, 142, 138, 107.12 [ 132 g: 150. 180, 195, 46, 240, 237. 144, 233, 143,28, 35, 162, 148, 86, 164, 84, 176, 2, 1 169.93. 75, 152, 127, 245, 234, 9, 16. 32, 186, 128, 213, 11, 71, 182,61, 177, 76. 131, 82, 117,216, 57, 222, 221, 69,59, 130, 150, 158, 67,3, 225, 249,21. 249, 21, 146 88, 189, 104, 27, 56, 194, 2, 49,214, 185, 247. 147, 45, 174, 10%, 6, 232, 100. 153, 175, 40. 41, 106, 66, 8 212. 184, 18, 235, 134, 243]: 3. I 63, 103, 00, 231,191, 91.65. 204, 208, 151,145 99, 203, ?, The above array is the in-stock inventory of different products sold by a index position corresponds to some other array that holds the product name) internal audit, you have been tasked to do the following: company (where each As part of an 6. (6 pts) Write a for loop to divisible by 8. Print the sum after the loop is complete. 7. (6 pts) Write a do loop to sum the values of all product inventories with values that are not divisible by 8. Print the sum after the loop is complete (6 pts) Write a while loop to sum the numbers not divisible by 5 in the range from 1 0. Print the sum after the loop is complete.

Explanation / Answer


var sum = 0;
for(var i=0;i<arrayInventory.length;i++) {
if(arrayInventory[i] % 8 != 0) {
sum = sum + arrayInventory[i];
}
}
document.write(sum);


var sum = 0;
var i=0;
do {
if(arrayInventory[i] % 8 != 0) {

sum = sum + arrayInventory[i];
}
i++;
}while(i<arrayInventory.length);
document.write(sum);


var sum = 0;
var i=1;
while(i<=100) {
if(arrayInventory[i] % 5 != 0) {
sum = sum + arrayInventory[i];
}
i++;
}

document.write(sum);