day11_BoxTest

육희영·2021년 10월 26일
0

상자 부피구하기

package com.java1.day11;

class Box {
	private int width;
	private int length;
	private int height;
	private int volume;

	Box(int w, int l, int h) {
		width = w;
		length = l;
		height = h;
		volume = width * length * height;
	}

	int getVolume() {
		return volume;
	}
}

public class BoxTest {

	public static void main(String[] args) {
		Box b;
		b = new Box(20, 20, 30);
		System.out.println("상자의 부피는 " + b.getVolume() + "입니다.");

	}

}

출력결과

상자의 부피는 12000입니다.

0개의 댓글

관련 채용 정보