-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMathClassMethods.java
More file actions
39 lines (26 loc) · 1.13 KB
/
Copy pathMathClassMethods.java
File metadata and controls
39 lines (26 loc) · 1.13 KB
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
import java.util.Scanner;
public class MathClassMethods{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter ineger: ");
int num = input.nextInt();
System.out.printf("The absolute value is %d%n",Math.abs(num));
//System
System.out.print("Enter a float-point number: ");
double num1 = input.nextDouble();
System.out.printf("The power value is %d%n",Math.pow(num1,2));
System.out.printf("The square root value is %f%n",Math.sqrt(num1));
System.out.println("===============================");
System.out.print("Enter the first number: ");
int number1 = input.nextInt();
System.out.print("Enter the second number: ");
int number2 = input.nextInt();
System.out.printf("The minimum number is %d%n",Math.min(number1,number2));
System.out.print("Enter the first number: ");
int number3 = input.nextInt();
System.out.print("Enter the second number: ");
int number4 = input.nextInt();
System.out.printf("The maximum number is %d%n",Math.max(number3,number4));
System.out.printf("The random number is %f%n",Math.random());
}
}