+ 1

How to check for a tech number in java?

Example 3025 = (30 + 25)²=(55)²=3025

17th Mar 2020, 5:21 AM
Aditya Banerjee
Aditya Banerjee - avatar
4 Réponses
0
My attempt: import java.io.*; import java.util.*; class Tech_Number {     public static void main(String args[])     {         Scanner in = new Scanner(System.in);         int n,l,a,b,sum,sq,div;         String str,str1,str2;         System.out.println("Enter Number");         str= in.nextLine();//input number as a string         l=str.length();//calculating length of string         n= Integer.parseInt(str);//converting input number as integer         if(l%2==0)         {             div= l/2;             str1= str.substring(0,div);//storing 1st half as string             str2= str.substring(div,l);//storing 2nd half as string             a= Integer.parseInt(str1);//converting 1st half into integer             b= Integer.parseInt(str2);//converting 2nd half into integer             sum= a+b; //sum of the two halves             sq= sum*sum; // square of sum of two halves             if(n==sq)             {                 System.out.println("It is a Tech Number : "+n);             }             else           
17th Mar 2020, 5:28 AM
Aditya Banerjee
Aditya Banerjee - avatar
0
Your attempt??
17th Mar 2020, 5:26 AM
Arsenic
Arsenic - avatar
0
You marked your answer as best does that mean you solved it
17th Mar 2020, 7:45 AM
Ore
Ore - avatar
0
Yes
17th Mar 2020, 7:46 AM
Aditya Banerjee
Aditya Banerjee - avatar