Cube root of a number in java. In this tutorial, we’ll construct two Java programs that use the For Loop and While Loop to find the cube of numbers up to a certain integer. Using the for and while loops, the program will find the cude of the first N numbers.

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

Scanner sc = new Scanner(System.in);

System.out.print("Enter the number ");

int num = sc.nextInt();

for (int i=1;i<=num;i++)

{

System.out.println("Number is "+i+" and cube of "+i+" is "+(i*i*i));

}

}

}

Output:

Enter the number 5

Number is 1 and cube of 1 is 1

Number is 2 and cube of 2 is 8

Number is 3 and cube of 3 is 27

Number is 4 and cube of 4 is 64

Number is 5 and cube of 5 is 125

## Cube Root in Maths

The component that we multiply by itself three times to generate a number is called the cube root. 3 cube root of, end cubic root is the symbol for cube root. Finding a number’s cube root is the inverse of cubing a number.

A cube root is a specific value that yields the required number when multiplied three times.

As a result, a perfect cube is a whole number cube. A cube root, on the other hand, is obtained by multiplying the lowest value three times to obtain the result.

## nextInt() in Java Program

nextInt() is a method that returns an integer. As an int, scans the next token of the input.

The invocation of this method with the form nextInt() acts in the same way as the invocation with the form nextInt(). nextInt(radix), where radix is the scanner’s default radix.

nextInt() A Scanner object’s nextInt() function takes a string of digits (characters) and transforms it to an int type.

The Scanner object scans each character one at a time until it has gathered all of the characters needed for one integer.

The data is then converted to a 32-bit numeric value. Using this program we can execute cube root of a number in java.