write a program in bluej to accept a number and check if it is a tech number or not
send fast
no spams
Answers
Answer:
import java.util.Scanner;
class Check
{
public static void main (String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a number");
int n=sc.nextInt();
int k=n,c=0,f=0,fs=0,ls=0,t=0,num=0;
while(k>0)
{
c=c+1;
k=k/10;
}
if(c%2==0)
{
c=c/2;
f=(int)Math.pow(10,c);
fs=n%f;
ls=n/f;
t=fs+ls;
num=(int)Math.pow(t,2);
if(num==n)
System.out.println("Tech Number");
else
System.out.println("Not a Tech Number");
}
else
{
System.out.println("Not a Tech Number");
}
}
}
import java.util.Scanner;
public class Equal_Integer
{
public static void main(String[] args)
{
int m, n;
Scanner s = new Scanner(System.in);
System.out.print("Enter the first number:");
m = s.nextInt();
System.out.print("Enter the second number:");
n = s.nextInt();
if(m == n)
{
System.out.println(m+" and "+n+" are equal ");
}
else
{
System.out.println(m+" and "+n+" are not equal ");
}
}
}
Output:
$ javac Equal_Integer.java
$ java Equal_Integer
Enter the first number:5
Enter the second number:7
5 and 7 are not equal
Enter the first number:6
Enter the second number:6
6 and 6 are equal