MATMATICAL FUNCTION
PI():- This is also a field of the Method class which returns you a default pi value, the ratio of the circumference of a circle to its diameter.
e.g System.out.println("pi = " + Math.round(Math.PI*100)/100f);
output ;- pi = 3.14
output ;- pi = 3.14
abs():- This is the abs() function which returns you the absolute number.
e.g. System.out.println("Absolute number = " + Math.abs(Math.PI));
output Absolute number = 3.141592653589793
output Absolute number = 3.141592653589793
ceil()This is the ceil() function which returns you the smallest value but greater than the argument.
System.out.println("Smallest value but greater than the argument = " + Math.ceil(Math.PI));
System.out.println("Round up Math.ceil(28.29)= " + Math.ceil(28.29));
System.out.println("Round up Math.ceil(-28.29)= " + Math.ceil(-28.29));
output:-
Smallest value but greater than the argument = 4.0
Round up Math.ceil(28.29)= 29.0
Round up Math.ceil(-28.29)= -28.0
exp()This is the exp() function which returns you the exponential value raised to the power of a double value.
System.out.println("Exponent number powered by the argument = " + Math.exp(0));
output:-
output:-
Exponent number powered by the argument = 1.0
floor()This is the floor() function which returns you the largest value but less than the argument.
System.out.println("Largest value but less than the argument = " + Math.floor(Math.E));
System.out.println("Round down Math.floor(28.89)= " + Math.floor(28.89));
System.out.println("Round down Math.floor(-28.89)= " + Math.floor(-28.89));
output:-
Largest value but less than the argument = 2.0
Round down Math.floor(28.89)= 28.0
Round down Math.floor(-28.89)= -29.0
max()This is the max() function which distinguishes the maximum value from the two given value.
System.out.println("Maximum Number = " + Math.max(10,10.3));
Output:-
Maximum Number = 10.3
min()This is the min() function which distinguishes the minimum value from the two given value.
System.out.println("Minimum Number = " + Math.min(10,10.3));
Output:- Minimum Number = 10.0
Output:- Minimum Number = 10.0
pow()This is the pow() function which returns you the number raised to the power of a first given value by the another one.
System.out.println("Power = " + Math.pow(10,3));
output:- Power = 1000.0
output:- Power = 1000.0
random()This is the random() function which returns you the random number. It is absolutely system generated.
System.out.println("Random Number = " + Math.random());
Output:-
Output:-
Random Number = 0.8746318896388414
rint()This is the rint() function which returns you a value closest to the given value.
System.out.println("Closest to the Argument = " + Math.rint(30));
Output:-
Output:-
Closest to the Argument = 30.0
round()This is the round() function which returns you a value that is in the rounded form.
System.out.println("Round = " + Math.round(2.72));
System.out.println("Round Math.round(28.89)= " + Math.round(28.89));
System.out.println("Round Math.round(28.29)= " + Math.round(28.29));
Output:-
Output:-
Round = 3
Round Math.round(28.89)= 29
Round Math.round(28.29)= 28
sqrt( ) This is the sqrt() function which returns you the square root of the specified value.
System.out.println("Square Root = " + Math.sqrt(400));
Output:- Square Root = 20.0
CHAPTER: CLASS AS BASIS OF ALL COMPUTATION WORKSHEET # 3
11) System.out.println(Math.sqrt(4.0)+Math.sqrt(9.0));
Ans______________________
Ans______________________
22) System.out.println(Math.pow(2,4))
Ans______________________
Ans______________________
33) System.out.println(Math.max(Math.max(2,3),Math.max(9,7)));
Ans______________________
Ans______________________
44) System.out.println(Math.min(Math.max(20,13),Math.min(9,7)));
Ans______________________
Ans______________________
55) System.out.println(Math.round(2.4));
Ans______________________
Ans______________________
66) System.out.println(Math.round(2.9));
Ans______________________
Ans______________________
77) System.out.println(Math.round(2.5));
Ans______________________
Ans______________________
88) System.out.println(Math.rint(2.4));
Ans______________________
Ans______________________
99) System.out.println(Math.rint(2.9));
Ans______________________
Ans______________________
110) System.out.println(Math.rint(2.5));
Ans______________________
Ans______________________
111) System.out.println(Math.rint(3.5));
Ans______________________
Ans______________________
112) System.out.println(Math.ceil(2.4));
Ans______________________
Ans______________________
113) System.out.println(Math.ceil(2.9));
Ans______________________
Ans______________________
114) System.out.println(Math.ceil(2.0));
Ans______________________
Ans______________________
115) System.out.println(Math.ceil(2.4));
Ans______________________
Ans______________________
116) System.out.println(Math.ceil(-2.4));
Ans______________________
Ans______________________
117) System.out.println(Math.ceil(-2.9));
Ans______________________
Ans______________________
118) System.out.println(Math.ceil(-2.0));
Ans______________________
Ans______________________
119) System.out.println(Math.floor(2.4));
Ans______________________
Ans______________________
220) System.out.println(Math.floor(2.9));
Ans______________________
Ans______________________
221) System.out.println(Math.floor(2.0));
Ans______________________
Ans______________________
222) System.out.println(Math.floor(-2.4));
Ans______________________
Ans______________________
223) System.out.println(Math.floor(-2.9));
Ans______________________
Ans______________________
224) System.out.println(Math.floor(-2.4)+Math.ceil(-2.4)+Math.round(2.7));
Ans______________________
Ans______________________
225) System.out.println(Math.abs(2.4)+Math.abs(-2.4));
Ans______________________
Ans______________________
226) System.out.println(Math.floor(-2.4));
Ans______________________
Ans______________________
227) System.out.println(Math.pow(4,1/2));
Ans______________________
Ans______________________
228) System.out.println(Math.pow(4,1.0/2));
Ans______________________
Ans______________________
229) System.out.println(Math.pow(4,Math.max(2,3)));
Ans______________________
Ans______________________
330) System.out.println(Math.ceil(Math.abs(-9.6));
Ans______________________
Ans______________________