- 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: Using Mathematical Functions
13. Write the equivalent Java statements for the following, by using the mathematical functions:
i. Print the positive value of -999.
ii. Store the value -3375 in a variable and print its cube root.
iii. Store the value 999.99 in a variable and convert it into its closest integer that is greater than or equal to 999.99.
import java.util.Scanner;
public class MathFunctionsDemo {
public static void main(String[] args) {
// i. Print the positive value of -999
int a = -999;
System.out.println("Positive value of -999 = " + Math.abs(a));
// ii. Store -3375 and print its cube root
double b = -3375;
System.out.println("Cube root of -3375 = " + Math.cbrt(b));
// iii. Convert 999.99 to the closest integer greater than or equal to it
double c = 999.99;
System.out.println("Closest integer >= 999.99 = " + (int)Math.ceil(c));
}
}
Output
Positive value of -999 = 999 Cube root of -3375 = -15.0 Closest integer >= 999.99 = 1000
Explanation
i. Positive value
- Math.abs() returns the absolute (positive) value of a number.
ii. Cube root
- Math.cbrt() calculates the cube root.
- Cube root of -3375 = -15
iii. Closest integer greater than or equal to
- Math.ceil() rounds a number upward.
- Type casting to int converts the result to an integer.
✅ Math Functions Used
| Function | Purpose |
|---|---|
|
Math.abs() |
Absolute value |
|
Math.cbrt() |
Cube root |
|
Math.ceil() |
Smallest integer ≥ number |
