Code is copied!
Program To Print Tech Number JAVA
Write a Program to print whether the inputted number is Tech or not.
[A tech number has even number of digits. If the number is split in two equal halves, then the square of sum of these halves is equal to the number itself.
Example:
Consider the number 3025
Square of sum of the halves of 3025 = (30 + 25)2
= (55)2
= 3025 is a tech number.]
import java.util.*; class technumber { public static void main(String[] args) { int num, leftNumber, rightNumber, digits = 0,sum = 0; Scanner sc = new Scanner(System.in); System.out.print("Enter number="); int n = sc.nextInt(); num = n; while (num > 0) { digits++; num = num / 10; } if (digits % 2 == 0) { num = n; leftNumber = num % (int) Math.pow(10, digits / 2); rightNumber = num / (int) Math.pow(10, digits / 2); sum = (leftNumber + rightNumber) * (leftNumber + rightNumber); if (n == sum) { System.out.println("Tech Number"); } else { System.out.println("Not Tech Number"); } } else { System.out.println("Not Tech Number"); } } }