Java program that calculates the square, cube, and fourth power of a number
###### Posted by Samath
Last Updated: February 08, 2021

Write a Java program that reads a number and displays the square, cube, and fourth power.

Example:

Square: 25.00

Cube: 125.00

Fourth Power: 625.00

```import java.util.Scanner;

public class Main
{
public static void main(String[] args) {

Scanner input = new Scanner(System.in);
double num;
double square_num;
double cube_num;
double fourth_num;

num = input.nextDouble();

input.close();

square_num = num * num;
cube_num = square_num * num;
fourth_num = cube_num * num;

System.out.printf("\nSquare: %.2f\n", square_num);
System.out.printf("Cube: %.2f\n",cube_num);
System.out.printf("Fourth Power: %.2f\n", fourth_num);

}
}
```
###### Square and Cube Class in C++
Samath | Jan 01, 2015
###### Power Function in Python
Samath | Mar 02, 2015
###### C Program to Calculate Area of Square
Samath | Jan 02, 2017
###### C program that determine if a number is a power of 2
Samath | Jun 03, 2015
###### C++ Power Set
Samath | Jan 05, 2017
###### C++ Magic Square
Samath | Jan 05, 2017
###### C Program to find exponent Power Series
Samath | Jan 02, 2017
###### C Program to print table of n and square of n using pow() Function
Samath | Jan 02, 2017
###### C Program to Check whether entered matrix is magic square or not
Samath | Jan 03, 2017
###### Write a C program to Print Square of Each Element of 2D Array Matrix
Samath | Jan 04, 2017