Thursday 5 November 2020

Write the JAVA program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by 7.

 

 

 Write the JAVA  program  to find  the number of  and sum  of all  integers greater than  100 and less than  200  that  are  divisible by 7.

 

 

PROGRAM :-

 

class SumofDigit

{

    public static void main(String  args[])

      {

          int sum = 0;

          int count = 0;

           for( int i = 100; i<=200; i++)

            {

               if(i % 7== 0)

                { 

                    sum + = i;

                     count++; 

                 }

            }

                 System.out.println("Number of  integers = "+count);

                 System.out.println("Sum of integers = "+sum);



        }

  

  }



OUTPUT :

Number of integers = 14

Sum of integers = 2107

 

 

 

No comments:

Post a Comment

Student Marks Calculation app using java

      import javax.swing. *; import java.awt.event.ActionEvent ; import java.awt.event.ActionListener ; public class Student { private J...