Advertisement
CoineTre

JF-LabMethods08.Math Power

Feb 5th, 2021
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1.  
  2. import java.text.DecimalFormat;
  3. import java.util.Scanner;
  4.  
  5. public class Lab8MathPower {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         double n = Double.parseDouble(scanner.nextLine());
  9.         int raisedBy = Integer.parseInt(scanner.nextLine());
  10.         double numberPower = getNumberPower(n,raisedBy);
  11.         System.out.println(new DecimalFormat("0.####").format(numberPower));
  12.  
  13.     }
  14.  
  15.     private static double getNumberPower(double n, int raisedBy) {
  16.         return Math.pow(n,raisedBy);
  17.     }
  18. }
  19.  
  20. //Create a method that calculates and returns the value of a number raised to a given power.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement