-
4. control - (3) IfDemo3 (if-else if문)java/코드 리뷰 2020. 3. 20. 15:051234567891011121314151617181920212223242526272829303132333435363738394041424344454647package control;public class IfDemo3 {public static void main(String[] args) {/*if ~ else if ~ else if ~ else 문3개 이상의 경우의 수를 처리해야 할 때 사용되는 조건문if (조건식1) {조건식1의 연산결과가 true로 판정될 때 실행될 수행문;} else if (조건식2) {조건식2의 연산결과가 true로 판정될 때 실행될 수행문;} else if (조건식3) {조건식3의 연산결과가 true로 판정될 때 실행될 수행문;} else (조건식4) {조건식1, 2, 3의 연산결과가 false로 판정될 때 실행될 수행문;}*//*구매금액이 500만원 이상인 경우 10만원 상품권 지급100만원 이상인 경우 1만원 상품권 지급50만원 이상인 경우 커피쿠폰 지급그 외에는 주차할인권 지급*/Scanner sc = new Scanner(System.in);System.out.print("구매금액을 입력하세요 : ");int orderPrice = sc.nextInt();if(orderPrice >= 5000000) {System.out.println("10만원 상품권 지급");} else if(orderPrice >= 1000000) {System.out.println("1만원 상품권 지급");} else if(orderPrice >= 500000) {System.out.println("커피쿠폰 지급");} else {System.out.println("주차할인권 지급");}}}
'java > 코드 리뷰' 카테고리의 다른 글
4. control - (5) IfDemo5 (중첩 if문) (0) 2020.03.23 4. control - (4) IfDemo4 (고객 등급) (0) 2020.03.23 4. control - (2) IfDemo2 (if문 - 짝수홀수) (0) 2020.03.20 4. control - (1) IfDemo1 (if문) (0) 2020.03.20 4. control - (2) Gugudan2 (구구단 출력) (0) 2020.03.20