JAVA 질문이요 ㅜㅜ...

JAVA 질문이요 ㅜㅜ...

작성일 2023.03.26댓글 1건
    게시물 수정 , 삭제는 로그인 필요

안녕하세요 자바 문제 푸는데 도저히 모르겠습니다... 할인 혜택 적용하는 문제이고 ...으로 되어 있는 부분 코드를 작성해야 합니다! 다른 건 작성한 상태입니다 ㅜㅜ
    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);

}
}



profile_image 익명 작성일 -

마지막이면 그냥 LGU+일 경우에는 둘 중 하나의 혜택만 적용 가능하니까

} else if (agency.equals("LGU+")) { int regular_sale = 0, time_sale = 0; 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_sale = total = (int) (total * 0.6); // 시간으로 받는 할인 금액 if (regular_sale > time_sale) total = total - regular_sale; else total = total - time_sale; }

regular_sale이 time_sale보다 크면 regular_sale을 빼주고 그게 아니면 time_sale을 빼주면 되는거 아닌가요?

그리고 저 코드에서는 time_sele이라고 되어있던데 time_sale 아닌가요

java코드 질문 ㅜㅜ

... import java.util.*; public class exam { public static void main(String[] args)... 이렇게하든...뭘하든 호출이 안되네요 ㅜㅜ 고수분들...

java 등 공부관련해서 질문이요 ! ㅜㅜ

... 다음 학기에는 java를 학교에서 배웁니다. 오라클, JSP... ㅜㅜ 자세하게 설명 부탁드립니다.. 오라클, JSP, MFC, my... 일단 질문자께서 무엇으 할지 정하는게 좋아 보이내요....

객체지향 프로그래밍 공부 c++, java 질문

... 하겠어서 질문드려요. 1. c++과 java 내용이 함께 있는 책은 없겠죠..?? 2. c++책은 이... java 는 책 추천 부탁드립니다..!! ㅜㅜ 답변 주시면 정말 정말 감사하겠습니다..!...

java 기초 질문이요 ㅜㅜ

system.out.println() 은 시스템이라는 클라스에 아웃이잇고 아웃에잇는 프린트라는 메소드로 동작이되는건가요????? 안녕하세요. out 참조변수는 System 클래스의...

Java 생 기초질문 ㅜㅜ

java를 이제 배우고있는데요 너무 어렵네요..ㅜㅜ 간단하게 IF 문과 SwitchCase문으로 학점... 편이라 질문마감률이 낮으면 글을 가려서 쓰는편...

Java 코딩 질문이요ㅜㅜ

... import java.util.Scanner; public class 연습문제_전화번호검색 { public static void main(String[] args) { // 이름,전화번호 저장 배열 String[] names...