[java] 자바의 정석 연습문제 ch03

3-1

===========================================

int x = 2;

int y = 5;

char c = 'A';

 

System.out.println(1+x<<33);

System.out.println(y>=5||x<0&&x>2);

System.out.println(y+=10-x++);

System.out.println(x+=2);

System.out.println(!('A'<=c&&c<='Z'));

System.out.println('C'-c);

System.out.println('5'-'0');

System.out.println(c+1);

System.out.println(++c);

System.out.println(c++);

System.out.println(c);

==========================================

6

true

13

5

false

2

5

66

B

B

C



3-2

int bucket = (num%size > 0)?(num/size)+1:num/size;

 

3-3

System.out.println(num>=0?num<=0?"0":"양":"음");

 

3-4

(num/100)*100

 

3-5

(num/10)*10+1

 

3-6

((num/10)*10+10)%num

 

3-7

float c = (float)((int)(((f-32)/1.8)*1000+0.5f))/1000f;

 

3-8

byte a = 10;

byte b = 20;

byte c = (byte)(a+b);

 

char ch = 'A';

ch = (char)(ch + 2);

 

float f = 3/2f;

long l = 3000 * 3000 * 3000l;

 

float f2 = 0.1f;

double d = 0.1;

 

boolean result = (float)d==f2;

 

3-9

ch >= ‘a’ && ch <=’z’ || ch >= ‘A’ && ch <= ‘Z’

 

3-10

 

(ch >= ‘A’ && ch <= ‘Z’)?(char)(ch+32):ch;