diff --git a/syamauchi/src/C117LargeStores.java b/syamauchi/src/C117LargeStores.java new file mode 100644 index 0000000000000000000000000000000000000000..b8e5211aedd7b4bd7b549e6a7c9a54846d308491 --- /dev/null +++ b/syamauchi/src/C117LargeStores.java @@ -0,0 +1,48 @@ +package src; + +import java.util.Scanner; + +public class C117LargeStores { + // お店の数、出店期間、建設費、賃金、商品一つごとの利益 + private final int numberOfStores; + private final int term; + private final int buildingCost; + private final int wage; + private final int profit; + + private C117LargeStores(final int numberOfSrores, final int term, final int buildingCost, + final int wage, final int profit) { + this.numberOfStores = numberOfSrores; + this.term = term; + this.buildingCost = buildingCost; + this.wage = wage; + this.profit = profit; + } + + public static void main(String[] args) { + final Scanner sc = new Scanner(System.in); + new C117LargeStores(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()) + .closeStore(sc); + sc.close(); + } + + private void closeStore(final Scanner sc) { + //閉店する店の数をカウント + int closeCount = 0; + //各店舗ごとに売り上げから採算が取れているか確認 + for (int i = 0; i < this.numberOfStores; i++) { + final int salesVolume = sc.nextInt() * this.profit; + //採算がとれていなければカウント + if (!isSurplus(salesVolume)) { + closeCount++; + } + } + System.out.println(closeCount); + } + + // その店舗が採算取れているのかのチェック + private boolean isSurplus(final int salesVolume) { + return (salesVolume - (this.term * this.wage + this.buildingCost) >= 0); + } + +}