ICSE Class 10 Computer Applications Question 59 of 76

Revising Basic Java Concepts — Question 63

Back to all questions
63
Question

Question 40

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

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");
    }
}
Output
BlueJ output of KboatMultipleCheck.java
BlueJ output of KboatMultipleCheck.java
Answer