This topic demonstrates about how to check number is divisible by given number or not using java program.

**Steps**

- Accept the number from user
- Find remainder of given number dividing by 7
- Check if remainder is 0 then display number is divisible by 7
- If remainder is non zero the display number is not divisible by 7

**Example**

import java.util.Scanner; public class NumberDivisibleCheckEx { public static void main(String[] args) { int number; Scanner scan = new Scanner(System.in); System.out.print("Enter any number : "); number = scan.nextInt(); if(number % 7 == 0) System.out.println(number+" is divisible by 7"); else System.out.println(number+" is Not divisible by 7"); } }

Enter any number : 28

28 is divisible by 7

28 is divisible by 7

import java.util.Scanner; public class NumberDivisibleCheckEx { public static void main(String[] args) { int LastNum; Scanner scan = new Scanner(System.in); System.out.print("Enter any last number in range : "); LastNum = scan.nextInt(); for(int i=1;i<LastNum;i++) { if(i % 7 == 0) System.out.println(i+" is divisible by 7"); } } }

Enter any last number in range : 100

7 is divisible by 7

14 is divisible by 7

21 is divisible by 7

28 is divisible by 7

35 is divisible by 7

42 is divisible by 7

49 is divisible by 7

56 is divisible by 7

63 is divisible by 7

70 is divisible by 7

77 is divisible by 7

84 is divisible by 7

91 is divisible by 7

98 is divisible by 7

7 is divisible by 7

14 is divisible by 7

21 is divisible by 7

28 is divisible by 7

35 is divisible by 7

42 is divisible by 7

49 is divisible by 7

56 is divisible by 7

63 is divisible by 7

70 is divisible by 7

77 is divisible by 7

84 is divisible by 7

91 is divisible by 7

98 is divisible by 7