Question: Java Loop Question Now you're going to sum up all the integers from 0 to 100 (inclusive) using any kind of loop you want (for,
Java Loop Question


Now you're going to sum up all the integers from 0 to 100 (inclusive) using any kind of loop you want (for, while, do I while, etc.). But the caveat is that you have to skip all numbers divisible by 10, so 10, 20, 30, 40, 50, 60, 70, 80, 90, and 100 are not included in the sum. You will write two loops. One will use an if statement that determines whether to add the numbers to the sum, and the other will use an if statement that sees if the number is divisible by 10 and will continue" the loop if it is. Your answer goes in SumZeroToOne HundredSkipTens.java 7e 20/* You're going to sum up the numbers 0 to 100 but you are 3 * going to skip any number divisible by 10. 4 */ 5 public class SumZeroToOne HundredskipTens { 6 public static void main(String[] args) { 8 9 // you can use any kind of loop you want 10 // have a counter that counts from 0 to 100 11 12 int sum = 0; 13 14 // the first loop has the structure of 15 // if (counter is not divisible by 10) 16 // then 17 // sum += counter; 18 19 20 // the second loop has the structure of: 21 // if (counter is divisible by 10) 22 // then 23 // continue 24 // and then it adds the counter to the sum if that condition does not execute 25 26 } sum = 0; 27 } 28
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
