목록코딩 (23)
S.S.G
int 타입의 width, height의 필드를 가지는 Rect 클래스를 작성하고, 두 Rect 객체의 width, height필드에 의해 구성되는 면적이 같으면 두 객체가 같은 것으로 판별하도록 equals()를 작성해보기. class Rect { int width; int height; public Rect(int width, int height) { this.width = width; this.height = height; } public boolean equals(Rect p) { if (width * height == p.width * p.height) return true; else return false; } } public class Test { public static void main(..
함수를 완성해서 매개변수 list의 평균값을 return 하도록 만들어 보기 public class Test { public int getAvg(int[] array) { int sum = 0; for(int i=0; i
* static 필드와 메소드를 이용하여 달러와 우리나라 원화 사이의 변환을 해주는 가단한 환율 계산기 public class Test { public static void main(String arg[]) { CurrentConverter.setRate(1160); // 미국 달러 환율 $1 는 1160원 System.out.println("백만원은 " + CurrentConverter.toDollar(1000000) + " 입니다."); System.out.println("백달러는"+ CurrentConverter.toKWR(100) + "원입니다."); } } class CurrentConverter { private static double rate; // 한국 원화에 대한 환율을 나타냄 publ..