package ch09.api;
import java.util.Arrays;
// java.lang.Math 클래
public class Ex01 {
public static void main(String[] args) {
double pi=Math.PI;
System.out.println(pi);
int a=Math.abs(-30);
System.out.println(a);
float b=Math.max(55.5f, 66.6f);
System.out.println(b);
int c=Math.min(10, -5);
System.out.println(c);
//소수첫째자리 반올림
float su=123.567f;
int d=Math.round(su);
System.out.println(d);
//소수 랜덤 뽑기
double e=Math.random();
System.out.println(e);
//1~10숫자 뽑기
int x=(int)(Math.random() *10) +1;
System.out.println(x);
//사람 뽑기
String[] array=new String[] {"aa", "bb", "cc", "dd", "gg"};
int index=(int)(Math.random() * array.length);
System.out.println(array[index]);
//주사위
int num=(int)(Math.random()*6)+1;
System.out.println(num);
//로또번호 뽑
int[] number=new int[6];
for(int i=0; i<number.length; i++) {
number[i]=(int)(Math.random()*45)+1;
//System.out.print(number[i] + "\\t");
}
Arrays.sort(number);
System.out.println(Arrays.toString(number));
}
}
3.141592653589793
30
66.6
-5
124
0.6604892463963461
1
cc
6
[5, 8, 27, 29, 37, 43]