Java Chapters

Java Program To Calculate Square And Cube Of Given Number

Structure of JAVA Programs - Overview
import java.util.Scanner;

public class Program 
{
    public static void main( String[] args ) 
    {
        int Number = 4, Square, Cube;
        
        Square = Number * Number;
        Cube = Number * Number * Number;
        
        System.out.println("Number is : " + Number);
        System.out.println("Square of " + Number + " is : " + Square);
        System.out.println("Cube of " + Number + " is : " + Cube);
    }
}

Output :
Number is : 4
Square of 4 is : 16
Cube of 4 is : 64

Leave a comment
Recent Comments
No Comments