JAVA 질문이요 ㅜㅜ...
-
게시물 수정 , 삭제는 로그인 필요
안녕하세요 자바 문제 푸는데 도저히 모르겠습니다... 할인 혜택 적용하는 문제이고 ...으로 되어 있는 부분 코드를 작성해야 합니다! 다른 건 작성한 상태입니다 ㅜㅜ
public static void main(String[] args) {
String agency = "SKT";
int hour = 9;
int cake = 20000;
int coffee = 12000;
int bread = 8000;
int total = cake + coffee + bread;
// if ( agency == "SKT") // 문자열끼리 ==연산은 저장된 위치가 같은지 묻는 것
if ( agency.equals("SKT") ) {
if ( total*0.15 > cake*0.25 )
//total = total - total *0.15
total = (int)(total * 0.85);
else
total = (int)(cake*0.75) + coffee + bread;
if ( 8 <= hour && hour <= 11 )
total = (int)(total * 0.9);
}
else if ( agency.equals("KT") ) {
if ( total*0.10 > bread*0.30 )
total = (int)(total * 0.9);
else
total = (int)(bread*0.7) + cake + coffee;
if (12 <= hour && hour <= 15 )
total = (int)(total * 0.8);
}
else if ( agency.equals("LGU+") ) {
int regular_sale, time_sele;
if ( total*0.1 > coffee*0.5)
regular_sale = (int)(total * 0.1);
else
regular_sale = total = (int)(coffee*0.5) + cake + bread; //정기할인 금액
if ( 17 <= hour && hour <= 20 )
time_sele = total = (int)(total * 0.6); // 시간으로 받는 할인 금액
if ( regular_sale > time_sele )
total = ...;
else
total = ...;
}
System.out.println(total);
}
}
public static void main(String[] args) {
String agency = "SKT";
int hour = 9;
int cake = 20000;
int coffee = 12000;
int bread = 8000;
int total = cake + coffee + bread;
// if ( agency == "SKT") // 문자열끼리 ==연산은 저장된 위치가 같은지 묻는 것
if ( agency.equals("SKT") ) {
if ( total*0.15 > cake*0.25 )
//total = total - total *0.15
total = (int)(total * 0.85);
else
total = (int)(cake*0.75) + coffee + bread;
if ( 8 <= hour && hour <= 11 )
total = (int)(total * 0.9);
}
else if ( agency.equals("KT") ) {
if ( total*0.10 > bread*0.30 )
total = (int)(total * 0.9);
else
total = (int)(bread*0.7) + cake + coffee;
if (12 <= hour && hour <= 15 )
total = (int)(total * 0.8);
}
else if ( agency.equals("LGU+") ) {
int regular_sale, time_sele;
if ( total*0.1 > coffee*0.5)
regular_sale = (int)(total * 0.1);
else
regular_sale = total = (int)(coffee*0.5) + cake + bread; //정기할인 금액
if ( 17 <= hour && hour <= 20 )
time_sele = total = (int)(total * 0.6); // 시간으로 받는 할인 금액
if ( regular_sale > time_sele )
total = ...;
else
total = ...;
}
System.out.println(total);
}
}
![](https://img-api.cboard.net/img_n.php?image_url=https://kin-phinf.pstatic.net/20230326_54/1679789328776O40kj_PNG/%BD%BA%C5%A9%B8%B0%BC%A6_2023-03-26_090825.png)