Java Online Compiler
Example: Find Power of a Number in Java using Math.pow() Function
C
C++
C#
Java
Python
PHP
Main.java
STDIN
Run
// Find Power of a Number in Java using Math.pow() Function import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); double b, x, r; // b - To store base number // x - To store exponent number // r - To store result value System.out.println ("-----Enter the input of base number-----"); b = in.nextFloat(); System.out.println ("\n-----Enter the input of exponent number-----"); x = in.nextFloat(); r = (double) Math.pow(b, x); System.out.println ("\nThe calculation of the power of N number is " + b + "^" + x + " = " + r); } }
10 3.5
Output
Clear
ADVERTISEMENTS