write a program to input two unequal positive number and check whether they are perfect square or not. if the user in the negative numbers in the program display message 'square root of negative number cannot be determined'.
Answers
Scanner sc = new Scanner(System.in);
int a,b;
a= sc.nextInt();
b = sc.nextInt();
if(a<0 // b<0)
System.out.println(message here);
else{
double aa,bb;
aa =math.sqrt(a);
bb = math.sqrt(b);
System.out.println(" a is "+ aa);
System.out.println(" b is "+ bb);
}
Answer:
HERE'S A SIMPLE ANSWER
HOPE IT HELPS
PLEASE MARK IT AS BRAINLIEST ANSWER
Explanation:
import java.util.*;
class P6
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter two numbers");
int a=sc.nextInt();
int b=sc.nextInt();
if(a<0||b<0)
{
System.out.println("Square Root of Negative Number cannot be determined");
}
else if(a>0)
{
double aa,bb;
aa =Math.sqrt(a);
bb =Math.sqrt(b);
if((aa*aa==a)&&(bb*bb==b))
{
System.out.println("These are perfect Squares");
}
else
{
System.out.println("These are not perfect Squares");
}
}
}
}