Posts

Showing posts with the label strontio number in java

Strontio Number in Java

Strontio numbers are the four-digit numbers which when multiplied by 2 gives the same digit at the hundreds and tens place. Example : 1386 is a strontio number because 1386 × 2 = 2772. We observe that we have the same digit at tens and hundreds place. 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 1001, 2002, 3003, etc. are some more examples of strontio numbers. Write a program in Java to input a four-digit integer and check whether it is a strontio number or not. import java.util.Scanner; class Strontio{     public static void main(String[] args) {         Scanner in = new Scanner(System.in);         System.out.print("Enter the number: ");         int n = Integer.parseInt(in.nextLine());         if(n < 1000 || n > 9999){             System.out.println("Not a strontio number.");             return;       ...