Advertisements
Q ?write an application that print out the even numbers between the range 100-200 ? 1- which aer not divisible by 7 and 5 ? 2- Number of the numbers which are not divisible by 7 and 5? 3- The summation of the numbers?
The given code prints out the even numbers between the range of 100 and 200 and then determine the even numbers which are not divisible by 5 and 7. It also find out the sum of all the even numbers between 100 and 200.
class EvenNumbers { public static void main(String[] args) { int sum=0; System.out.println("Even Numbers between 100 and 200"); for(int i=100;i<=200;i++){ if(i%2==0){ sum+=i; System.out.println(i); } } System.out.println("Even Numbers between 100 and 200 which are not divisible by 5 and 7"); for(int i=100;i<=200;i++){ if(i%2==0){ if((i%7!=0)&&(i%5!=0)){ System.out.println(i); } } } System.out.println("Sum of even numbers: "+sum); } }