Skip to content

Instantly share code, notes, and snippets.

@Starlight258
Last active January 15, 2024 08:01
Show Gist options
  • Save Starlight258/aee21f1b9659944a7ab8e5c563fc567d to your computer and use it in GitHub Desktop.
Save Starlight258/aee21f1b9659944a7ab8e5c563fc567d to your computer and use it in GitHub Desktop.
0114_과제3
// 김명지
import java.util.Scanner;
public class a3 {
static final int BASIC_PRICE = 10000;
static final int SPECIAL_DISCOUNT_PRICE = 4000;
static final int NORMAL_DISCOUNT_PRICE = 8000;
public static void main(String[] args) {
System.out.println("[입장권 계산]");
Scanner sc = new Scanner(System.in);
System.out.print("나이를 입력해 주세요.(숫자):");
int age = sc.nextInt();
System.out.print("입장시간을 입력해 주세요.(숫자입력):");
int entranceTime = sc.nextInt();
System.out.print("국가유공자 여부를 입력해 주세요.(y/n):");
Boolean nationalFlag = sc.next().equals("y");
System.out.print("복지카드 여부를 입력해 주세요.(y/n):");
Boolean cardFlag = sc.next().equals("y");
// 입장료 계산하기
int price = BASIC_PRICE;
if (age < 3) {
price = 0;
} else if (age < 13 || entranceTime > 17) {
price = SPECIAL_DISCOUNT_PRICE;
} else if (nationalFlag || cardFlag) {
price = NORMAL_DISCOUNT_PRICE;
}
System.out.printf("입장료: %d", price);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment