-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathMathOperations
46 lines (36 loc) · 1.33 KB
/
MathOperations
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
public class MathOperations {
public static void main(String[] args) {
double num1 = 10.5;
double num2 = 5.5;
// Addition
double sum = num1 + num2;
System.out.println("Sum: " + sum);
// Subtraction
double difference = num1 - num2;
System.out.println("Difference: " + difference);
// Multiplication
double product = num1 * num2;
System.out.println("Product: " + product);
// Division
double quotient = num1 / num2;
System.out.println("Quotient: " + quotient);
// Modulo
double modulus = num1 % num2;
System.out.println("Modulus: " + modulus);
// Power
double power = Math.pow(num1, num2);
System.out.println("Power: " + power);
// Square root
double squareRoot = Math.sqrt(num1);
System.out.println("Square Root of num1: " + squareRoot);
// Absolute value
double absoluteValue = Math.abs(num2);
System.out.println("Absolute Value of num2: " + absoluteValue);
// Floor value
double floorValue = Math.floor(num1);
System.out.println("Floor Value of num1: " + floorValue);
// Ceiling value
double ceilingValue = Math.ceil(num2);
System.out.println("Ceiling Value of num2: " + ceilingValue);
}
}