Sunday, November 3, 2013

Calculate Cube Root using JAVA

import java.util.*; //Packeage required to use Scanner class
class Root
{
public static void main(String x[])
{
Scanner sc=new Scanner(System.in);//To accept inputs using Scanner reference
System.out.println("Enter number"); // To display the message
double n=sc.nextDouble(); // Accept the user input in 'double' data type and
                         // and store it in variable 'n'

System.out.println("Cube root of "+n+" is "+Math.pow(n,1.0/3)); // Calculate cube root and                                                                                                                           //display it

}
}
OUTPUT



I tried to keep this program as simple as I could. However if you have still any questions , suggestions , feedback or any other thing , feel free to comment in the comment section below.
I'll be very glad to hear from you about this blog.
Happy Programming!!!!


No comments:

Post a Comment