본문 바로가기
Java

이것이 자바다 - 챕터3 연습 문제

by Jiwon_Loopy 2025. 4. 5.
반응형

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
반응형