반응형
3번 - 학생 1명의 연필 수와, 남은 연필 수 구하기
int pencils = 534;
int students = 30;
int pencilsPerStudent = pencils / students;
System.out.println(pencilsPerStudent);
int pencilsLeft = pencils % students;
System.out.println(pencilsLeft);
4번 - 십의 자리 이하를 버리는 코드 만들기 (산술 연산자만 사용)
int value = 356;
System.out.println(value - value%100);
728x90
반응형
'Java' 카테고리의 다른 글
| 이것이 자바다 - 챕터5 연습 문제 (0) | 2025.04.05 |
|---|---|
| 이것이 자바다 - 챕터4 연습 문제 (0) | 2025.04.05 |
| 4/4 공부 기록 - 참조 타입, 클래스 (8) | 2025.04.05 |
| 4/3 - 변수, 조건문, 반복문 (0) | 2025.04.05 |
| 4/2 변수와 타입, 연산자 (0) | 2025.04.05 |