Skip to content

Instantly share code, notes, and snippets.

@youngvctr
Last active June 2, 2023 19:20
Show Gist options
  • Save youngvctr/6608d0eab5657ebc24a5912461cbbb59 to your computer and use it in GitHub Desktop.
Save youngvctr/6608d0eab5657ebc24a5912461cbbb59 to your computer and use it in GitHub Desktop.
/*
김정훈
2023-06-01 | 조건문 순서를 가장 큰 금액으로 할인받을 수 있는 순서로 배치하였습니다.
*/
import java.util.Scanner;
public class JavaStudy03 {
public static void main(String[] args) {
System.out.println("[입장권 계산]");
System.out.printf("나이를 입력해 주세요.(숫자):");
Scanner sc = new Scanner(System.in);
int age = sc.nextInt();
System.out.printf("입장시간을 입력해 주세요.(숫자입력):");
sc = new Scanner(System.in);
int admissionTime = sc.nextInt();
System.out.printf("국가유공자 여부를 입력해 주세요.(y/n):");
sc = new Scanner(System.in);
String nationalMerit = sc.next();
System.out.printf("복지카드 여부를 입력해주세요.(y/n):");
sc = new Scanner(System.in);
String welfareBenefit = sc.next();
int admissionFee = 10000;
if (age < 3) admissionFee -= 10000;
else if (age < 13 || admissionTime >= 17) admissionFee -= 6000;
else if (nationalMerit.equals("y") || welfareBenefit.equals("y")) admissionFee -= 2000;
System.out.printf("입장료: %d", admissionFee);
}
}
@youngvctr
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment