import java.util.Scanner;
public class TechNumber {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
int num = sc.nextInt();
int count = 0, temp = num;
while (temp > 0) {
int digit = temp % 10;
if (digit % 2 == 0) {
count++;
}
temp /= 10;
}
if (num % count == 0) {
System.out.println(num + " is a Tech number.");
} else {
System.out.println(num + " is not a Tech number.");
}
sc.close();
}
}
Enter a number: 246
246 is a Tech number.
Enter a number: 280
280 is not a Tech number.
Scanner
class. We then count the number of even digits in the number by dividing the number by 10 repeatedly and checking the remainder of each division. We use a while loop for this.if-else
statement. If it is divisible, we print that the number is a Tech number, otherwise we print that it is not a Tech number.