ICSE Class 10 Computer Applications Question 13 of 14

Mathematical Library Methods — Question 13

Back to all questions
13
Question

Question 13

Write the equivalent Java statements for the following, by using the mathematical functions:

i. Print the positive value of -999.

Answer
System.out.println(Math.abs(-999));

ii. Store the value -3375 in a variable and print its cube root.

int a = -3375;
System.out.println(Math.cbrt(a));

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.

double a = 999.99;
System.out.println(Math.round(a));