AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
3. Our Experts are looking for yours ?.

# corejava-programming: Print the sum of following numbers

 Write a program in Java to print the sum of all numbers from 50 to 250 (inclusive of 50 and 250) that are multiples of 3 and not divisible by 9. Input specification: There should be no input from the user. Output specification: The sum of integers from 50 to 250 that are multiples of 3 and not divisible by 9 followed by a new line. corejava x 352programming x 168 Posted On : 2016-08-02 23:05:06.0 Boopalan 3730 2

 public class PrintNumbers { public static void main(String arg[]) { int sum=0; for(int i=50;i<251;i++) //For-loop for numbers 50-250 { if(i%3==0 & i%9!=0) // Condition to check if number should be divided by 3 and not divided by 9 { System.out.println(i); //Individual number which are selected in loop sum=sum+i; //Adding values of array so that total sum can be calculated } } //Final display output for the code System.out.println("\n The sum of intergers from 50 to 250 that are multiples of 3 and not divisible by 9 :" +sum); } } Posted On : 2016-08-03 08:29:54 Satisfied : 1 Yes  0 No 6

 public class PrintNumbers { public static void main(String arg[]) { int sum=0; for(int i=50;i<=250;i++){ //For-loop for numbers 50-250 if(i%3==0 & i%9!=0){ // Condition to check if number should be divided by 3 and not divided by 9 sum=sum+i; //Adding values of array so that total sum can be calculated } } System.out.println(sum); } } Posted On : 2016-08-03 11:48:05 Satisfied : 1 Yes  0 No Rishi Kumar 523188221945Reply This Thread 5