Computer Science, asked by Anonymous, 27 days ago

7. Write a java program To accept a number and check and display whether it is an even number or not. (Even number is that number which is divisible by its sum of digits) close. Example : Consider the number 126. Sum of its digits is 1 + 2 + 6 = 9 and 126 is divisible by 9.​

Answers

Answered by mpd20700
1

Answer:

import java.util.*;

public class HelloWorld

{

    public static void main(String []args)

    {

        Scanner sc = new Scanner(System.in);

        System.out.println("Enter a number:");

        int n=sc.nextInt();

        int sum=0;

        int temp = n;

        while(temp > 0)

       {

           temp = temp % 10;

           sum = sum+temp;

           temp = temp/10;

       }

       if(n%sum==0)

       {

           System.out.println("The number entered is an even number");

       }

       else

       {

           System.out.println("The number entered is not an even number");

       }      

    }

}

Similar questions