In: Computer Science
Below is the code in java with className as "Main"(Main.java). If you wish to save the file name as suppose(Xyz.java), change the Class name from 'Main'(in first line of program) to whatever you wish (Xyz). attached the code image as well and the output result's image)
public class Main
{
public static void main(String[] args)
{
int sum=0;
System.out.println("Sample Output:\n");
System.out.println("Numbers between 200 and 250, divisible by 7: ");
for(int i=200;i<250;i++)
{
if(i%7==0)
{
System.out.print(i+" ");
sum =sum+i;
}
}
System.out.println("\nThe sum is: "+sum);
}
}
Code image :(change the highlighted part(className) if you wish to save the file with some other name. Suppose if you want to save this java file as (Water.java), change the highlighted part(marked in below image)(very first line of code) from 'Main' to 'Water'.
Output result :