divideFive.java

less than 1 minute read

This program was created to simply check if a number is divisible by 5.

Prints true if it does or else false.

The code has been modified slightly and now uploaded to the site.

<— Return Home

Code Snippet

public class divideFive {
    public static void main(String[] args){
        boolean result = divisibleByFive(5);
        boolean result2 = divisibleByFive(-55);
        boolean result3 = divisibleByFive(37);
        System.out.println(result);
        System.out.println(result2);
        System.out.println(result3);
    }
    public static boolean divisibleByFive(int num){
        boolean checker = false;
        if (num % 5 == 0){
            checker = true;
        }
        return checker;
    } 
}

<— Return Home