From f315fcfbcc3e0cbfbdef697f9747fa4f71d3467b Mon Sep 17 00:00:00 2001 From: Islandec235 Date: Sun, 19 Nov 2023 21:07:46 +0300 Subject: [PATCH] code review --- .idea/.gitignore | 3 + .idea/misc.xml | 6 ++ .idea/modules.xml | 8 +++ .idea/uiDesigner.xml | 124 ++++++++++++++++++++++++++++++++++++++ .idea/vcs.xml | 6 ++ m1-t12-code-style.iml | 11 ++++ src/DepositCalculate.java | 57 ++++++++++++++++++ 7 files changed, 215 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 m1-t12-code-style.iml create mode 100644 src/DepositCalculate.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..dda71418 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..28678352 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 00000000..2b63946d --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/m1-t12-code-style.iml b/m1-t12-code-style.iml new file mode 100644 index 00000000..c90834f2 --- /dev/null +++ b/m1-t12-code-style.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/DepositCalculate.java b/src/DepositCalculate.java new file mode 100644 index 00000000..fa7d7a27 --- /dev/null +++ b/src/DepositCalculate.java @@ -0,0 +1,57 @@ +import java.util.Scanner; + +public class DepositCalculate { + double calculateComplexPercent(double amount, double yearRate, int depositPeriod) { + double pay = amount * Math.pow((1 + yearRate / 12), 12 * depositPeriod); + + return roundNumber(pay, 2); + } + + double calculateSimplePercent(double amount, + double yearRate, int depositPeriod) { + + return roundNumber(amount + amount + * yearRate * depositPeriod, 2); + } + + double roundNumber(double value, int power) { + double scale = Math.pow(10, power); + + return Math.round(value * scale) / scale; + } + + void calculateProfitDeposit() { + int period; + int action; + int amount; + + Scanner scanner = new Scanner(System.in); + + System.out.println("Введите сумму вклада в рублях:"); + amount = scanner.nextInt(); + + System.out.println("Введите срок вклада в годах:"); + period = scanner.nextInt(); + + System.out.println("Выберите тип вклада, " + + "1 - вклад с обычным процентом, " + + "2 - вклад с капитализацией:"); + action = scanner.nextInt(); + + double sumDeposit = 0; + + if (action == 1) { + sumDeposit = calculateSimplePercent(amount, 0.06, period); + } else if (action == 2) { + sumDeposit = calculateComplexPercent(amount, 0.06, period); + } + + System.out.println("Результат вклада: " + + amount + " за " + period + + " лет превратятся в " + sumDeposit); + } + + public static void main(String[] args) { + new DepositCalculate().calculateProfitDeposit(); + } +}