- Home
- Chapter 1 - Object Oriented Programming Concepts
- Object Oriented Programming Concepts
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 2 - Introduction to Java
- Introduction to Java
- Multiple Choice Questions
- Assignment Questions
- Chapter 3 - Values and Data Types
- Values and Data Types
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 4 - Operators in Java
- Operators in Java
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 5 - User-Defined Methods
- User-Defined Methods
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 6 - Input in Java
- Input in Java
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 7 - Mathematical Library Methods
- Mathematical Library Methods
- Multiple Choice Questions
- Assignment Questions
- Chapter 8 - Conditional Constructs in Java
- Conditional Constructs in Java
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 9 - Iterative Constructs in Java
- Iterative Constructs in Java
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions and Programs
- Chapter 10 - Nested for loops
- Nested for loops
- Assignment Questions and Programs
- Chapter 11 - Constructors
- Constructors
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 12 - Library Classes
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 13 - Encapsulation and Inheritance
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 14 - Arrays
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 15 - String Handling
- Library Classes
- Multiple Choice Questions
- Assignment Questions
Mathematical Library Methods
Chapter 7
Mathematical Library Methods
Class 10 - Logix Kips ICSE Computer Applications with BlueJ
![]() Share with a Friend |
Java Program: Power and Square Root Calculation
Write a program to print:
- x to the power y
- the square root of y
The values of x and y are 81 and 3, respectively.
public class PowerAndSquareRoot {
public static void main(String[] args) {
int x = 81;
int y = 3;
// Calculations
double power = Math.pow(x, y);
double squareRoot = Math.sqrt(y);
// Output
System.out.println("x to the power y = " + power);
System.out.println("Square root of y = " + squareRoot);
}
}
Output
x to the power y = 531441.0 Square root of y = 1.7320508075688772
Explanation
- Math.pow(x, y) calculates xʸ
813 = 53144181
- Math.sqrt(y) calculates the square root of y
√3 ≈ 1.732
✅ Concepts Used
- Math.pow() – power calculation
- Math.sqrt() – square root calculation
📌 Formatted Output (Optional)
System.out.printf("x to the power y = %.0f\n", power);
System.out.printf("Square root of y = %.3f", squareRoot);
