Write a program in Java
to input any number and check
wheather the number is divisible by 8 or not
give the output also ..?
Answers
Answer:
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int num=s.nextInt();
if(num%8==0){
System.out.println(num+" is Divisible by 8");
System.out.println("answer = "+num/8);
}
else
System.out.println(num+" is not divisible by 8");
}
}
Explanation:
Output:
16
16 is Divisible by 8
answer = 2
import java.util.*;
class p4
{
public static void main(String args[ ])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a number");
int a=sc.nextInt();
if(a%8= =0)
System.out.println("The number is divisible by 8");
else
System.out.println("The number is not divisible by 8");
}
}
Enter a number: 32
The number is divisible by 8.
OR
Enter a number: 36
The number is not divisible by 8.
(Remainder is not equal to zero)
Hope this answer will help you!!❤✌