Showing posts with label Perfect cube. Show all posts
Showing posts with label Perfect cube. Show all posts

Sunday, June 21, 2020

Write a program to input a number and check whether it is Perfect Cubes Number or not? (27 cubes of 3, 64 cubes of 4)

23)  Write a program to input a number and check whether it is Perfect Cubes Number or     not? (27 cubes of 3, 64 cubes of 4)

import java.util.*; 
public class Perfect_cube
{
    public static void main(String args[ ])
    {
        Scanner sc = new Scanner (System.in);
        System.out.println("Enter a number");
        double a = sc.nextInt();
        double b = Math.cbrt(a);
        int c = (int)b;
        if(b==c)
        {
            System.out.println("Entered number is a PERFECT CUBE number");
        }
        else
        {
             System.out.println("Entered number is not a PERFECT CUBE number");
        } 
    }
}

 jhvghvgk ;nkjn ,nkjhj