Java
[Java] JAVA의 정석 기초편 챕터3 문제
oneH
2024. 8. 30. 23:28
public class JavaChapter3 {
public static void main(String[] args) {
Practice3_3 p33 = new Practice3_3();
Practice3_4 p34 = new Practice3_4();
Practice3_5 p35 = new Practice3_5();
Practice3_6 p36 = new Practice3_6();
}
}
class Practice3_3 {
int num = 456;
Practice3_3() {
System.out.println((this.num - (this.num % 100)));
}
}
class Practice3_4 {
int numOfApples = 121;
int sizeOfBucket = 10;
int numOfBucket;
Practice3_4() {
this.numOfBucket = (this.numOfApples % this.sizeOfBucket > 0) ? this.numOfApples / this.sizeOfBucket + 1 : this.numOfApples / this.sizeOfBucket;
System.out.println("필요한 바구니의 수 :" + this.numOfBucket);
}
}
class Practice3_5 {
int num = 10;
Practice3_5() {
System.out.println((this.num) > 0 ? "양수" : (this.num) < 0 ? "음수" : 0);
}
}
class Practice3_6 {
int fahrenheit = 100;
float celcius = 0f;
Practice3_6() {
System.out.println("fahrenheit:" + this.fahrenheit);
this.celcius = (int) (((float) 5 / 9) * ((float) this.fahrenheit - 32) * 100 + 0.5f) / 100f;
System.out.println("celcius:" + this.celcius);
}
}
임시 포스팅...