개발속이야기/Java

SmartPhone 클래스 작성

스토리지기 2017. 12. 28. 10:02

입력 출력을 하기 위한 예제입니다.


SmartPhone 클래스 작성

   phoneName 
   출고가
   월정액
   할부개월
   할부수수료 = 연 6.1%
   선택약정요금할인(%) = 25%
   통신요금

SmartPhone iphoneX = new SmartPhone("아이폰X", 1360700, 24, 109890);
iphoneX.info();

폰이름: ...
출고가:...
단말구매가(수수료포함):...
할부개월: 24
월정액: 109890
지원금: -27500
월 납부금액: 단말구매가 + 월정액-지원금 


-------------------------------------------------------------


public class SmartPhone {
private String phoneName;
private double phonePrice; // 출고가
private double monPrice; // 단말구매가
private int monTotal; // 할부개월
private double priceRate = 0.0626d; // 할부수수료 
private double disPrice; // 선택약정요금할인
private double telPrice; // 월정액
private double totalPrice; // 통신요금
public SmartPhone(String phoneName, double phonePrice, int monTotal, double telPrice) {
super();
this.phoneName = phoneName;
this.phonePrice = phonePrice;
this.monTotal = monTotal;
this.telPrice = telPrice;
this.monPrice = Math.ceil((phonePrice + (phonePrice * priceRate))/this.monTotal);
this.disPrice = Math.ceil((telPrice * 0.25)/100)*100;
this.totalPrice = Math.ceil( this.monPrice + telPrice - disPrice );
}
public void info()
{
System.out.println("폰이름: " + this.phoneName);
System.out.println("출고가: " + this.phonePrice);
System.out.println("단말구매가: " + this.monPrice);
System.out.println("할부개월: " + this.monTotal);
System.out.println("월정액: " + this.telPrice);
System.out.println("지원금: " + this.disPrice);
System.out.println("월 납부금액: " + this.totalPrice);
}
}


public class SmartPhoneTest {
public static void main(String[] args) {
SmartPhone iphoneX = new SmartPhone("아이폰X", 1360700, 24, 109890);
iphoneX.info();
}

}



'개발속이야기 > Java' 카테고리의 다른 글

Java Thread 예제  (0) 2017.12.28
lamdba식 예제  (0) 2017.12.28
체질량 예제  (0) 2017.12.28
JAVA File 관련 예제  (0) 2017.12.28
JFrame JPanel 예제  (0) 2017.12.28