summaryrefslogtreecommitdiffstats
path: root/Java/PowerOfANumber.java
diff options
context:
space:
mode:
Diffstat (limited to 'Java/PowerOfANumber.java')
-rw-r--r--Java/PowerOfANumber.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/Java/PowerOfANumber.java b/Java/PowerOfANumber.java
new file mode 100644
index 0000000..18858d1
--- /dev/null
+++ b/Java/PowerOfANumber.java
@@ -0,0 +1,24 @@
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+class PowerofaNumber {
+ public static void main(String[] args) throws java.io.IOException {
+ BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
+ BufferedReader input2 = new BufferedReader(new InputStreamReader(System.in));
+ System.out.println("Enter X");
+ int x = Integer.parseInt(input.readLine());
+ System.out.println("Enter N");
+ float n = Float.parseFloat(input2.readLine());
+ if (n > 0){
+ System.out.println(n + " raised to the power of " + x + " is: " + Math.pow(n,x));
+ }
+ else{
+ System.out.println("n cannot be negative");
+ }
+
+
+ }
+
+
+}
+//By msglm; Licensed under the AGPL v3