In: Computer Science
I have uploaded the Images of the code, Typed code and Output of the Code. I have provided explanation using comments(read them for better understanding).
Images of the Code:
Note: If the below code is missing indentation
please refer code Images
Typed Code:
public class Main
{
public static void main(String[] args) {
//initializing i as 200 and sum as 0
int i = 200,sum = 0;
System.out.println("Numbers between
200 and 250, divisible by 7:");
//while loop will iterate till "i"
value become bigger than 250
while(i <= 250)
{
//if i value is divisible by
7
if(i%7==0)
{
//printing the number
System.out.print(i+"\t");
//adding the number to sum
sum = sum + i;
}
//increment i value
i++;
}
System.out.println();
//printing the sum
System.out.print("The sum is
"+sum);
}
}
//code ended here
Output:
If You Have Any Doubts. Please Ask Using Comments.
Have A Great Day!