Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class Lab8MathPower {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double n = Double.parseDouble(scanner.nextLine());
- int raisedBy = Integer.parseInt(scanner.nextLine());
- double numberPower = getNumberPower(n,raisedBy);
- System.out.println(new DecimalFormat("0.####").format(numberPower));
- }
- private static double getNumberPower(double n, int raisedBy) {
- return Math.pow(n,raisedBy);
- }
- }
- //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