import java.awt.*;
// Need this import for reading data:

// reading data in a Java application
public class Power {

    public static void main (String [] args) throws IOException {
	// Create a buffered reader
	BufferedReader in = new BufferedReader(
			new InputStreamReader(;
	// string for storing a line of input
	String line;

	// Read one integer
	// prompt the user:
        System.out.print("Please enter a number: ");
	// read a line of input:
	line = in.readLine();
	// extract a double:
	double n = Double.parseDouble(line);
	// compute the cube of n
	double cube = Math.pow(n, 3);
	System.out.println("The cube of n is " + cube);

This is an example from CSci 1211 course.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.