forked from chennakrishnans/JAVA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsquare.java
More file actions
42 lines (40 loc) · 737 Bytes
/
Copy pathsquare.java
File metadata and controls
42 lines (40 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.*;
public class square
{
public static void main (String[] args)
{
try
{
Scanner sc=new Scanner(System.in);
int i;
System.out.println("Enter lower number: ");
int l=sc.nextInt();
System.out.println("Enter upper number: ");
int u=sc.nextInt();
if(l>u)
{
System.out.println("The upper limit need to be high");
}
if(l<=0||u<=0)
{
System.out.println("Enter the valid limit");
}
if(l==u)
{
System.out.println("The both limit not should be equal");
}
else
{
for (i = l; i <= u; i++)
{
if (Math.sqrt(i) == (int)Math.sqrt(i))
System.out.print(i + " ");
}
}
}
catch(Exception e)
{
System.out.println("Enter the valid limit");
}
}
}