Computer Science, asked by GeekyJS, 6 months ago

write the JAVA program​

Attachments:

Answers

Answered by anindyaadhikari13
3

Here is your program for the given question.

import java.util.*;

class Number

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

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

int n=sc.nextInt();

if(n%3==0&&n%5==0)

System.out.println("Number is divisible by 3 and 5.");

else if(n%3==0&&n%5!=0)

System.out.println("Number is divisible by 3 but not by 5.");

else of(n%3!=0&&n%5==0)

System.out.println("Number is divisible by 5 but not by 3.");

else

System.out.println("Number is neither divisible by 3 nor by 5.");

}

}

Answered by TheUntrustworthy
94

import java.util.";

class Divisibility

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in); System.out.print("Enter a number: ");

int n=sc.nextInt();

if(n%3==0&&n%5==0)

System.out.println("Number is divisible by 3 and 5.");

else if(n%3==0&&n%5!=0)

System.out.println("Number is divisible by 3 but not by 5.");

else if(n%3!=0&&n%5==0)

System.out.println("Number is divisible by 5 but not by 3.");

else

System.out.println("Number is neither divisible by 3 nor by 5.");

}

}

Similar questions