-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path4.1 Perfect Cube or Not.java
52 lines (39 loc) · 1.09 KB
/
4.1 Perfect Cube or Not.java
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
/*
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
*/
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();
boolean check = false;
for(int i=0;i<n;i++)
{
int cube = i*i*i;
if(cube == n)
{
System.out.print("Perfect Cube");
check = true;
break;
}
}
if(check == false)
System.out.print("Not Perfect Cube");
}
}