You are on page 1of 6

MATH CLASS

CC203 COMPUTER PROGRAMMING 2


Math class
provides helpful static methods for
performing numeric operations such as
exponential, logarithm, etc.
abs()
The abs() method returns the absolute value of a given value.
pow()
Calculates and returns the value of the first argument raised to the power of
the second one.
sqrt()
Returns the rounded positive square root of a double.
cbrt()
Similarly, cbrt() returns the cube root of a double.
max()
As the method's name suggests, it returns the maximum between
two values.
min()
In the same way, min() returns the minimum between two values.
ceil()
To round a number to the largest double that is greater than or
equal to the argument.
floor()
To round a number to the largest double that is less than or equal
to the argument.
round()
To round a number to the nearest one.
Java If-else Statement
The Java if statement is used to test
the condition. It checks boolean
condition: true or false.
There are various types of if
statement in Java.

• if statement
• if-else statement
• if-else-if ladder
• nested if statement
Conditional Operators
• Less than: <
• Less than or equal to: a <= b
• Greater than: a > b
• Greater than or equal to: a >= b
• Equal to a == b
• Not Equal to: a != b

You might also like