Answer:
import java.util.Random;
public class MathTest {
public static void main(String[] args) {
int a = 37, b = 300;
double c = 22.8;
int max;
System.out.println("The Square root of 37 is "+ Math.sqrt(a));
System.out.println("The Sine of 300 is " + Math.sin(b) + " and the cosine is "+ Math.cos(b));
System.out.println("The Floor, Ceiling and Round Value of 22.8 respectively are "+Math.floor(c)+", "+Math.ceil(c)
+", "+Math.round(c));
max = Math.max((int)'D',71);
System.out.println("The Maximum between D and 71 is " +max );
Random rand = new Random();
int RandValue = rand.nextInt(20);
System.out.println("A random Number between 0 and 20 is "+ RandValue);
}
}
Explanation:
In order to get the square root of the number 37, the square root function is called by the statement Math.sqrt(a) since the value 37 has been assigned to a. Method calls are also applied to find the cosine, sine, floor, round and ceiling values for the respective variables.
To determine the maximum between the character 'D' and the integer 71, we first cast the character 'D' to an integer using this (int)'D'. Then we make the Method call Math.max( ).
To generate a random variable between 0 and 20, we first make an object of the class Random we use this object to obtain a random number between 0 and 20 by specifying the bound to 20 during the method call.