Java Program To Compute Square And Cube Of Number
Write Java program to compute square and cube of the number
// WAP to find square and cube of given number
import java.util.Scanner;
public class Compute
{
public static void main(String []args)
{
long n,square,cube;
//object 'sc' created to scan data
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number :--> ");
n = sc.nextLong();
square = n*n;
cube = n*n*n;
System.out.println("Square is :--> " + square);
System.out.println("Cube is :--> " + cube);
}
}
Output: