KnowledgeBoat Logo

Computer Applications

Write a program that inputs a number and tests if the given number is a multiple of both 3 and 5.

Java

Java Conditional Stmts

9 Likes

Answer

import java.util.Scanner;

public class KboatMultipleCheck
{
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter number: ");
        int num = in.nextInt();
        
        if (num % 3 == 0 && num % 5 == 0)
            System.out.println("Multiple of 3 and 5");
        else
            System.out.println("Not a multiple of 3 and 5");
    }
}

Variable Description Table

Program Explanation

Output

BlueJ output of Write a program that inputs a number and tests if the given number is a multiple of both 3 and 5.BlueJ output of Write a program that inputs a number and tests if the given number is a multiple of both 3 and 5.

Answered By

4 Likes


Related Questions