OneCompiler

Tech Number using java

469

import java.util.Date;
import java.util.;
public class HelloWorld {
public static void main(String[] args) {
String str2="";
String st="";
String pt="";
int j=0,k=0;
Scanner sc= new Scanner(System.in);
String digit=sc.next();
int tech=Integer.parseInt(digit);
char[] ch = digit.toCharArray();
int eg=(ch.length)-1;
for(int i=0;i<eg-1;i++)
{
char ch1=ch[i];
str2 = String.valueOf(ch1);
st=st+str2;
}
k=Integer.parseInt(st);
for(int i=eg-1;i<ch.length;i++)
{
char ch1=ch[i];
str2 =String.valueOf(ch1);
pt=pt+str2;
}
j=Integer.parseInt(pt);
int square=(j+k)
(j+k);
if(square==tech)
{
System.out.println("The first half number is " +k);
System.out.println("The second half number is "+j);
System.out.println("The square of the sum of first half and second half number is "+square);
System.out.println("The number itself is "+
tech);
System.out.println("Therefore It is a tech number");
}
else
{
System.out.println("The first half number is " +k);
System.out.println("The second half number is "+j);
System.out.println("The square of the sum of first half and second half number is "+square);
System.out.println("The number itself is "+
tech);
System.out.println(" Therefore It is not a tech number");
}
}
}