Computer Science, asked by sushmita1233, 1 year ago

WAP to enter a no and check whether it is a tech no. or not.

Using java and function parameter

Please give the defination of tech no.​


amannishad0512p5zxh6: pls mention in tech no. also

Answers

Answered by amannishad0512p5zxh6
1

Definition of Tech Number

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 halves of 3025

=(30+25)^2

=55^2

=3025 is a tech number.

import java.util.*;

class Tech

{

public int tech(int n1)

{

int t=0,m=0,l,sum=0;

String a,f="",d="";

a=Integer.toString(n1);

l=a.length();

f=a.substring(0,l/2);

d=a.substring(l/2);

t=Integer.parseInt(f);

m=Integer.parseInt(d);

sum=(int)Math.pow((t+m),2);

return(sum);

}

public static void main ( String args[ ])

{

Scanner sc=new Scanner (System.in);

Tech ob=new Tech();

int n,l,check=0;

System.out.println("Enter your number");

n=sc.nextInt();

String k=Integer.toString(n);

l=k.length();

if(k==4)

{

check=ob.tech(n);

if(check==n)

System.out.println("Tech Number");

else

System.out.println("Not a Tech Number");

}

else

System.out.println("Not a Tech Number");

}

}

Hope my friend Sushmita, you are satisfied with the answer. I m 1st to answer this question.

Please Compile the Program .

If any query then submit in Comments,I will surely tell you.

If your program runs smoothly and you get your doubt resolved,then only Mark me Brainlest,if you like.

Have a great day !

Similar questions