Write a Java program to check whether the given integer is a multiple of 5


The program starts by prompting the user to enter a number using the print statement System.out.print("Enter The Number : ");.

The program then reads in the user's input using a Scanner object and stores it as an integer variable num.

The program then checks whether num is a multiple of 5 by using the conditional statement if(num%5==0).

If num is a multiple of 5, the program prints out the message num+" is a Multiple of 5". If num is not a multiple of 5, the program prints out the message num+" is not a Multiple of 5".

Source Code

import java.util.Scanner;
class Multiple_Five
{
	public static void main(String[] args)
	{
		System.out.print("Enter The Number : ");
		Scanner input = new Scanner(System.in);
		int num =input.nextInt();    
		if(num%5==0)
		{
			System.out.println(num+" is a Multiple of 5");
		}
		else
		{
			System.out.println(num+" is not a Multiple of 5");
		}
	}
}

Output

Enter The Number : 5690
5690 is a Multiple of 5

Example Programs