From 0308a3e5a1ee6586cb532cb0735359ababd40973 Mon Sep 17 00:00:00 2001 From: syamauchi Date: Wed, 28 Jun 2023 16:10:34 +0900 Subject: [PATCH 1/2] =?UTF-8?q?C117=E5=9B=9E=E7=AD=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- syamauchi/src/C117LargeStores.java | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 syamauchi/src/C117LargeStores.java diff --git a/syamauchi/src/C117LargeStores.java b/syamauchi/src/C117LargeStores.java new file mode 100644 index 0000000..37600e8 --- /dev/null +++ b/syamauchi/src/C117LargeStores.java @@ -0,0 +1,49 @@ +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(this.term, this.buildingCost, this.wage, salesVolume)) { + closeCount++; + } + } + System.out.println(closeCount); + } + + // その店舗が採算取れているのかのチェック + private boolean isSurplus(final int term, final int buildingCost, final int wage, + final int totalProfit) { + return (totalProfit - (term * wage + buildingCost) >= 0); + } + +} -- GitLab From c75a11915b9db9cf3a7232e16c17f03e48b0fbef Mon Sep 17 00:00:00 2001 From: syamauchi Date: Wed, 28 Jun 2023 16:14:29 +0900 Subject: [PATCH 2/2] =?UTF-8?q?C117=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- syamauchi/src/C117LargeStores.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/syamauchi/src/C117LargeStores.java b/syamauchi/src/C117LargeStores.java index 37600e8..b8e5211 100644 --- a/syamauchi/src/C117LargeStores.java +++ b/syamauchi/src/C117LargeStores.java @@ -33,7 +33,7 @@ public class C117LargeStores { for (int i = 0; i < this.numberOfStores; i++) { final int salesVolume = sc.nextInt() * this.profit; //採算がとれていなければカウント - if (!isSurplus(this.term, this.buildingCost, this.wage, salesVolume)) { + if (!isSurplus(salesVolume)) { closeCount++; } } @@ -41,9 +41,8 @@ public class C117LargeStores { } // その店舗が採算取れているのかのチェック - private boolean isSurplus(final int term, final int buildingCost, final int wage, - final int totalProfit) { - return (totalProfit - (term * wage + buildingCost) >= 0); + private boolean isSurplus(final int salesVolume) { + return (salesVolume - (this.term * this.wage + this.buildingCost) >= 0); } } -- GitLab