Last active
July 7, 2023 17:00
-
-
Save rorrorome/582f673423bd544556443778ae998fa4 to your computer and use it in GitHub Desktop.
입장료
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 제로베이스 백엔드 스쿨 15기 | |
* 한새롬 | |
* 미니과제 3. 놀이동산 입장권 계산 프로그램 | |
* | |
* Scanner의 입력함수와 다중 조건문을 통한 입장권 계산 로직 작성 | |
* 1. 놀이공원 입장료를 구하는 조건에 맞게 로직 작성 | |
* 2. 입력내용은 나이, 입장시간, 국가유공자 여부, 복지카드 여부 순으로 입력 | |
* 놀이공원 입장료 할인은 일반 할인과 특별 할인이 있습니다. | |
조건은 아래와 같습니다. | |
입장료 할인은 중복할인 되지 않으며, 중복될 경우 가장 할인을 많이 받은 금액으로 정해집니다. | |
- 3세미만이면 무료 입장 | |
- 복지카드와 국가유공자의 경우 일반 할인 적용 | |
- 13세미만이면 특별 할인 적용 | |
- 17시이후에 입장하면 특별 할인 적용 | |
기본 입장료 : 10,000원 | |
특별 할인의 경우 : 4,000원 | |
일반 할인의 경우 : 8,000원 | |
*/ | |
import java.util.Scanner; | |
//Scanner 사용 | |
public class MiniProject03 { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
// 입력순서 | |
System.out.println("[입장권 계산]"); | |
System.out.print("나이를 입력해 주세요. (숫자): "); | |
int age = sc.nextInt(); | |
System.out.print("입장시간을 입력해 주세요. (숫자입력): "); | |
int time = sc.nextInt(); | |
System.out.print("국가유공자 여부를 입력해 주세요. (y/n): "); | |
String national = sc.next(); | |
System.out.print("복지카드 여부를 입력해 주세요. (y/n): "); | |
String disable = sc.next(); | |
int fee = 10000; | |
// 다중조건문 사용 계산로직 | |
if (age < 3) { | |
fee = 0; | |
} else if (age < 13 && age >= 3 || time >= 17) { | |
fee = 4000; | |
} else if (national.equals("y") || disable.equals("y")) { | |
fee = 8000; | |
} else { | |
fee = 10000; | |
} | |
// 입장료 출력 | |
System.out.println("입장료: " + fee); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment