From 43df550bbb9e28d241ba40da29b68ad8aaa9b5e6 Mon Sep 17 00:00:00 2001 From: Popov-PV <105174297+Popov-PV@users.noreply.github.com> Date: Sat, 11 Jun 2022 21:27:17 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B2=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D1=8B=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=B2=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=B4=20=D1=81=D0=BE=D0=B3=D0=BB=D0=B0=D1=81=D0=BD=D0=BE=20Cod?= =?UTF-8?q?eStyle=20=D0=AF=D0=BD=D0=B4=D0=B5=D0=BA=D1=81.=D0=9F=D1=80?= =?UTF-8?q?=D0=B0=D0=BA=D1=82=D0=B8=D0=BA=D1=83=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 3 ++ .idea/misc.xml | 6 +++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 +++ m1-t12-code-style.iml | 11 +++++ .../m1-t12-code-style/DepositCalculator.class | Bin 0 -> 2449 bytes src/DepositCalculator.java | 46 ++++++++++++++++++ src/calculate_deposit.java | 40 --------------- 8 files changed, 80 insertions(+), 40 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 m1-t12-code-style.iml create mode 100644 out/production/m1-t12-code-style/DepositCalculator.class create mode 100644 src/DepositCalculator.java delete mode 100644 src/calculate_deposit.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/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/out/production/m1-t12-code-style/DepositCalculator.class b/out/production/m1-t12-code-style/DepositCalculator.class new file mode 100644 index 0000000000000000000000000000000000000000..d7d3ec3d059c2d642a8123f786785354753adb18 GIT binary patch literal 2449 zcmaJ@TUQfT7~MmzgpnYS5EN~!AOSDbOR<2rN@|UQqVZB|Z99Z1j7erv zdrJafTntxQiE-VBq!3Pv;f4=4C3sJ1x@Mk{;EMI#lHeXSrc?>RF-=#m6tk0R{)RG{ zp{8}rNGX|HN?sFkMd>zYw1R}TvACKu3Ys~pWKzY9VjB4o2_4*TOX{eR&1KX_6KX!C z>Lz{0;_*aZoD(H$6op2j;Gb2M{B^~ovmH|o9xXIuipvScms4gXgsY%QO@LN0{e=fb z2B%L;@WdQ+&qF0sB$_vuQBo@7^b}}K#m*`S%?k{PYu;SNmsd%dnxRYZaks9kd6D0J z<)JcAG_}k?(or%$mr-QoJCdf7N{=hKcO}Ux8jZuTyN*#t(WeKJrig6BF0hiH7A4ze zSwbLb6j`GSnus!7SJWdS3>mx8<-;u*xABFHgE%DP4!&eobwT=YSH@SkCrrMU@iD%U zaMF5dEm}*~A6BV6XDvm`Ka`(X>(+YtNtF6kYt35V+5&}W`7xJXTWjSPbf57%fIVw4!K z%g@X6)*ITdN3FL6*eE|`9&eb%hP8eudaT}PmASmN9W5}glC{Dxp7Ob5{W&b7ANyr| zi2V{;&KrhVF!M@oTs3EmsY1{T)sOFFOk;+Ht!spgkI+RsyW)0-uTI`qQ=~)lrfOU< zY3#}w-`kXo3&MNyY>fZ2?Hm7ECoOp+T@GL%Xp%mvk|pILv27Ow zuQp94$hA$AHaj39)u_qsoY<5Rt}2l4^VFxSkIaNPo4go!wP?66Va$5P;;oPtYvrF< z_=WOZO{1)Z;iwc9RThsmcA2Z9Q%lw&M{XvQ=18~~G>S^RA+k!EmxG>C%-fnd!&$*p z?937+$4=*Hfb#UB6d4NxePfz~}q}QA@U@u3p32@;9j zQG$pM&k8ldI1fL+Kv!?DuN@6WsznZYX68$9r-!`#5wB+%p5M6cU>1$}bvxvY7nyxHDZr!nr=EKVf4!VWZQjtyx zVP{1+-8|&!a=$`bf5<)Gj@I4FXdm+Yf>4*|6 z%U1<0j&asNkQgM>zXbRC&>=}aG)m;cPX4Vq$z2Zh zhKM6^XVV%w?yMlPjLuE=I!xL+^ H_`CKWarTVI literal 0 HcmV?d00001 diff --git a/src/DepositCalculator.java b/src/DepositCalculator.java new file mode 100644 index 00000000..5d08e253 --- /dev/null +++ b/src/DepositCalculator.java @@ -0,0 +1,46 @@ +import java.util.Scanner; + +public class DepositCalculator { + double calculateComplexPercent(double amount, double yearRate, int depositPeriod) { + double pay = amount * Math.pow((1 + yearRate / 12), 12 * depositPeriod); + return squaring(pay, 2); + } + + double calculateSimplePercent(double amount, double yearRate, int depositPeriod) { + return squaring(amount + amount * yearRate * depositPeriod, 2); + } + + double squaring(double value, int places) { + double scale = Math.pow(10, places); + return Math.round(value * scale)/ scale; + } + + void calculatePersents() { + int period; + int action; + Scanner scanner = new Scanner(System.in); + + System.out.println("Введите сумму вклада в рублях:"); + int amount = scanner.nextInt(); + + System.out.println("Введите срок вклада в годах:"); + period = scanner.nextInt(); + + System.out.println("Выберите тип вклада, 1 - вклад с обычным процентом, 2 - вклад с капитализацией:"); + action = scanner.nextInt(); + + double moneySum = 0; + if (action == 1) { + moneySum = calculateSimplePercent(amount, 0.06, period); + } else if (action == 2) { + moneySum = calculateComplexPercent(amount, 0.06, period); + } + System.out.println("Результат вклада: " + amount + " за " + period + " лет превратятся в " + moneySum); + } + + public static void main(String[] args) { + new DepositCalculator().calculatePersents(); + } + + +} diff --git a/src/calculate_deposit.java b/src/calculate_deposit.java deleted file mode 100644 index 90164f11..00000000 --- a/src/calculate_deposit.java +++ /dev/null @@ -1,40 +0,0 @@ -import java.net.URI;import java.util.Scanner;import java.io.IOException; - -public class calculate_deposit -{ -double Calculate_Complex_Percent_Function(double a, double y,int d ) { - double pay = a * Math.pow((1 + y/ 12), 12 *d); - return rnd(pay, 2); - } double Calculate_Simple_Percent_Function(double doubleAmount,double double_year_rate, int deposit_period) { - return rnd(doubleAmount+doubleAmount * double_year_rate *deposit_period, 2); - } double rnd(double value - ,int places) { - double ScaLe= Math.pow - (10, places); - return Math.round(value*ScaLe) - /ScaLe; } - - void do_important_job( ) - { - int period, action ; - Scanner abcdef = new Scanner(System.in); System.out.println("Введите сумму вклада в рублях:") ; - int amount = abcdef.nextInt(); System.out.println("Введите срок вклада в годах:") ; - period = abcdef.nextInt( ); - System.out.println ( "Выберите тип вклада, 1 - вклад с обычным процентом, 2 - вклад с капитализацией:"); - action = abcdef.nextInt(); - double outDoubleVar = 0; - if (action ==1) outDoubleVar = Calculate_Simple_Percent_Function(amount, 0.06, period); - else if (action == 2) - { - outDoubleVar = Calculate_Complex_Percent_Function(amount, 0.06, period); } - System.out.println("Результат вклада: " + amount + " за " + period + " лет превратятся в " + outDoubleVar); - } -public static void main(String[] args) - { - new calculate_deposit().do_important_job(); -} - - - - -}