write a program in java to take a value from the user and print the square of it, unless it is more than 120. The message “I cannot square numbers” should appear if the user assigns too large a number.
Answers
Answered by
1
Answer:
import java.util.*
public class Number
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int n,s;
System.out.println("Enter a number");
n=sc.nextInt();
if(n<=100)
{
s=n*n;
if(s>=120)
System.out.println("The square of number is:"+s);
}
else
System.out.println("I can not find the square");
}
}
}
HOPE IT HELPS YOU
Similar questions