RGAlex

O8. Math Power

Feb 5th, 2021
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. package LabMethods;
  2.  
  3. import java.text.DecimalFormat;
  4. import java.util.Scanner;
  5.  
  6. public class O8MathPower {
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.         double number = Double.parseDouble(scanner.nextLine());
  10.         int power = Integer.parseInt(scanner.nextLine());
  11.         printResult(number, power);
  12.  
  13.     }
  14.  
  15.     private static void printResult(double number, int power) {
  16.         double result = Math.pow(number, power);
  17.         System.out.println(new DecimalFormat("0.####").format(result));
  18.     }
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment