write a java program to check whether an int type number(taken as input) is a 3-digit number divisible by three or not
Answers
Answer:
I am a python coder so I am writing the logic so please write the code in java according to logic.
Explanation:
Firstly ask for the number.....
Then convert the number as a string and find the length of string.
Then use if - else...
If number == 3 and number % 3 == 0
In python we use "%" for finding the remainder
I hope you understood.......
Thanks
Adrika Bhadauria
class 7
Answer: The required java program is :-
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Enter an integer : ");
int num = scan.nextInt();
if(num>=100 && num<=999){
if(num%3 == 0) {
System.out.println("The number "+num+" is a three digit number which is divisible by 3.");
}
else {
System.out.println("The number "+num+" is a three digit number but is not divisible by 3.");
}
}
else {
System.out.println("The number "+num+" is not a three digit number.");
}
}
}
Please mark it as Brainliest.