Write a java program to enter a number and check whether it is a multiple of 2 or multiple of 3 or multiple of 2 and 3 both using if else.
plzz answer it clearly.
Answers
Answered by
4
import java.util.*;
{
public static void main (String args [])
{
Scanner sc=new Scanner (System.in);
System.out.println("enter a number");
int n=sc.nextInt();
if(n%2==0)
{
System.out.println("it is multiple of 2");
}
else if(n%3==0)
{
System.out.println("it is multiple of 3");
}
else if (n%2==0 && n%3==0)
{
System.out.println("it is multiple of 2 and 3");
}
}
}
Anonymous:
welcome
Similar questions
Geography,
7 months ago
Science,
7 months ago
Math,
7 months ago
Psychology,
1 year ago
Math,
1 year ago
Computer Science,
1 year ago
Math,
1 year ago