Computer Applications

Write valid statements for the following in Java:

i. Print the rounded off value of 14.49

ii. Print the absolute value of -0.09

iii. Print the largest of -67 and -50

iv. Print the smallest of -56 and -57.4

v. Print a random integer between 25 and 35

vi. Print 47.5 raised to the power 6.3

vii. Print minimum of -4, -7

Java Math Lib Methods

9 Likes

Answer

i. Print the rounded off value of 14.49

System.out.println(Math.round(14.49));

ii. Print the absolute value of -0.09

System.out.println(Math.abs(-0.09));

iii. Print the largest of -67 and -50

System.out.println(Math.max(-67, -50));

iv. Print the smallest of -56 and -57.4

System.out.println(Math.min(-56, -57.4));

v. Print a random integer between 25 and 35

int range = 35 - 25 + 1;
int num = (int)(range * Math.random() + 25);
System.out.println(num);

vi. Print 47.5 raised to the power 6.3

System.out.println(Math.pow(47.5, 6.3));

vii. Print minimum of -4, -7

System.out.println(Math.min(-4, -7));

Answered By

7 Likes


Related Questions