-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDay04_prob2.java
More file actions
54 lines (38 loc) · 1.08 KB
/
Day04_prob2.java
File metadata and controls
54 lines (38 loc) · 1.08 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
/*
Alex has got a Mathematical assignment where he has to find whether a given integer N is a Perfect Cube or not.Write a Java program solution to help Alex
Input Format
First line will contain an integer N
Constraints
N>1 & N<1000
Output Format
return "Perfect Cube" If given integer is a perfect Cube or "Not Perfect Cube" incase it is not
Sample Input 0
125
Sample Output 0
Perfect Cube
Sample Input 1
515
Sample Output 1
Not Perfect Cube
*/
// kirtan jain
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc=new Scanner(System.in);
int N=sc.nextInt(), flag=0;
for (int i = 0; i <= N; i++) {
int cube = i * i * i;
if (cube == N) {
flag=1;
System.out.println("Perfect Cube");
break;
}
}
if(flag==0){
System.out.println("Not Perfect Cube");
}
}
}