Computer Science, asked by keshavchandraag10, 4 months ago

WAP to input a number and check whether
multiple of 3 and 5 ore or not​

Answers

Answered by allysia
4

Language:

JAVA

Program:

import java.util.*;

public class boo {

public static void main(String[] args) {

 Scanner scan = new Scanner (System.in);

 System.out.print("Enter a number: ");

 int x= scan.nextInt();

 if (x%15==0) {System.out.print("It is divisible by 3 and 5" );}

 else if (x%3==0) {System.out.println("It is divisible by 3." );}

 else if (x%5==0){System.out.println("It is divisible by 5." );}

 else {System.out.println("It is divisible by none." );}}}

Output:

Consider the attachment.

Explanation:

  • Takes number input in x.
  • If x divisible by 15, it's divisible by 5 and 3.
  • If x divisible by 3 or 5, program returns respective elements.
  • If not divisible by either 3 or 5, it returns associated statement.

Attachment:

Attachments:
Similar questions