write a java program to find my lucky number or not

Write a java program to find my lucky number or not. Thilagar intended to give his car a four-digit fortunate number. The numbers 3,5 and 7 are auspicious for him. Assist him in locating the number whose sum is divisible by three, five, or seven. Please provide a valid vehicle identification number. If a valid input is not provided, the message “This number is not a valid vehicle number” is displayed.

import java.util.Scanner;
public class Main
{
public static void main (String[] args)
{
Scanner sc= new Scanner(System.in);
System.out.println("Enter the vehicle number");
int num=sc.nextInt();
if(num<1000 || num>9999)
{
System.out.println(num+" is not a valid vehicle number");
}
else
{int sum=0;
while(num>0)
{
sum+=num%10;
num/=10;
}
if(sum%3==0 || sum%5==0 || sum%7==0)
{
System.out.println("Lucky number");
}
else
{
System.out.println("Sorry its not my lucky number");
}
}
}
}

 

Output:

Enter the vehicle number
9897
Lucky number