Java Program to Find Square, Cube, and Square Root of an Integer Number

Java program to find Square, Cube, and Square Root of an integer number

// Java Program to find square, square root 
// and cube of a given number

import java.util.*;

public class j5 {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int num;

        System.out.print("Enter an integer number: ");
        num = sc.nextInt();

        System.out.println("Square of " + num + " is: " + Math.pow(num, 2));
        System.out.println("Cube of " + num + " is: " + Math.pow(num, 3));
        System.out.println("Square Root of " + num + " is: " + Math.sqrt(num));
    }
}

Output

Enter an integer number: 12
Square of 12 is: 144.0
Cube of 12 is: 1728.0
Square Root of 12 is: 3.4641016151377544
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment