ICSE Class 10 Computer Applications Question 9 of 14

Mathematical Library Methods — Question 9

Back to all questions
9
Question

Question 9

Write a program to print:

i. x to the power y

ii. the square root of y

The values of x and y are 81 and 3, respectively.

Answer
public class KboatNumber
{
    public static void main(String args[]) {
        int x = 81;
        int y = 3;
        
        double r1 = Math.pow(x, y);
        System.out.println("x to the power of y = " + r1);
        
        double r2 = Math.sqrt(y);
        System.out.println("Square root of y = " + r2);
    }
}
Output
BlueJ output of KboatNumber.java