public class Test2 {
public static void main(String[] args) {
int kor, eng, math, total;
kor = 75;
eng = 60;
math = 100;
total = kor + eng + math;
//평균
double average = total / 3.0;
System.out.println("total : " + total + ", average : " + average);
}
}
public class CharTypeUnicode {
public static void main(String[] args) {
char ch1 = '헐';
char ch2 = '확';
char ch3 = 54736;
char ch4 = 54869;
char ch5 = 0xD5D0;
char ch6 = 0xD655;
System.out.println(ch1 + " " + ch2);
System.out.println(ch3 + " " + ch4);
System.out.println(ch5 + " " + ch6);
}
}
[Console]
헐 확
헐 확
헐 확
public class Boolean {
public static void main(String[] args) {
boolean b1 = true;
boolean b2 = false;
System.out.println(b1);
System.out.println(b2);
int num1 = 10;
int num2 = 20;
System.out.println(num1 < num2);
System.out.println(num1 > num2);
}
}
[Console]
true
false
true
false
public class Constants {
public static void main(String[] args) {
final int MAX_SIZE = 100;
final char CONST_CHAR = '상';
final int CONST_ASSIGNED;
CONST_ASSIGNED = 12;
System.out.println("상수1 : " + MAX_SIZE);
System.out.println("상수2 : " + CONST_CHAR);
System.out.println("상수3 : " + CONST_ASSIGNED);
}
}
[Console]
상수1 : 100
상수2 : 상
상수3 : 12
public class RoundArea {
public static void main(String[] args) {
final double PI = 3.14;
double r = 10;
double round = PI * r * r;
System.out.println("원의 넓이 : " + round);
}
}