package jp.co.jid.etc;

public class Exercise01 {
	private static final int FREE_PRICE = 0;
	private static final int ADULT_PRICE = 1000;
	private static final int CHILD_PRICE = 800;
	private static final int CHILD_PRICE_AGE = 6;
	private static final int ADULT_PRICE_AGE = 20;
	private static final int ELDERLY_PRICE_AGE = 60;
	private static final int ULTRA_ELDERLY_PRICE_AGE = 100;
	private static final int DISCOUNT_AGE1 = 5;
	private static final int DISCOUNT_AGE2 = 3;
	private static final double DISCOUNT_PER1 = 1 - 0.05;
	private static final double DISCOUNT_PER2 = 1 - 0.03;
	private static final double DISCOUNT_PER3 = 1 - 0.10;

	public static void main(String[] args) {
		System.out.println("入場料は" + getValue(1) + "円です");
	}

	private static int getValue(int age) {
		if (age < CHILD_PRICE_AGE) {
			return FREE_PRICE;
		} else if (age < ADULT_PRICE_AGE) {
			return discount(CHILD_PRICE, age);
		} else if (age < ELDERLY_PRICE_AGE) {
			return discount(ADULT_PRICE, age);
		} else if (age < ULTRA_ELDERLY_PRICE_AGE) {
			return elderlyPrice(age);
		} else {
			return FREE_PRICE;
		}
	}

	private static int discount(int price, int age) {
		if (age % DISCOUNT_AGE1 == 0 && age % DISCOUNT_AGE2 == 0) {
			return (int) (price * DISCOUNT_PER3);
		} else if (age % DISCOUNT_AGE1 == 0) {
			return (int) (price * DISCOUNT_PER1);
		} else if (age % DISCOUNT_AGE2 == 0) {
			return (int) (price * DISCOUNT_PER2);
		}
		return price;
	}

	private static int elderlyPrice(int age) {
		return (int) (ADULT_PRICE * ((ULTRA_ELDERLY_PRICE_AGE - age) / 100d));
	}
}
