From a985c87ee638f79fe2691faaf2804744001d5ef7 Mon Sep 17 00:00:00 2001 From: Freddycs Date: Mon, 12 Dec 2022 15:28:46 +0300 Subject: [PATCH 1/2] first operation code-style --- .idea/.gitignore | 3 ++ .idea/encodings.xml | 6 +++ .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 -> 2477 bytes src/DepositCalculator.java | 39 +++++++++++++++++ src/calculate_deposit.java | 40 ------------------ 9 files changed, 79 insertions(+), 40 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/encodings.xml 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/encodings.xml b/.idea/encodings.xml new file mode 100644 index 00000000..19d7366f --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file 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..46aa635de4d7797d4c6b76a873204d97d472eb0f GIT binary patch literal 2477 zcmaJ@TUQfT7~KQ85k_ty5G~lWf&{!!rPTt87gB2!yv0kcwe66MFlI87CKD@f7MHS? zb}iTPsgJ((twmZO1;qD0O@2rJL)(2OV?aZjteiRLJLlW``@XZ!nf&?p>IQ(Lu!7iy z?j9sJ0n$ZdpLKAT{XBISTT+vfSU9rskC_V0IMta=L=5+P`B{iQ? z4U2TKcs$V`XGh7JMPZRR2+XQV{)%FeXGgjMMGwtPb2=fR(K0PXKjk{K3f!b7aI3Jv zY1O(yytGOeZ>&P$y{G6!Li%#Ll2RF`x4;x=Xc4Q`LQ%KexFz^GWf*E+By(4}rwkS? zO&?5Fj7-LtbK_|!7Sw#g$Q4C0c?X0+CoLtFnN)Ib>XKD7LqbRFRs~E~jOoFomDh~v zQK!mEep=LRn`sHbq*-LO&S)akj+)9I6yeEu4_$s-mvIAM$k>PdGH&8a39U83`*BOg zSGX-)zLxO~zLjv)er_+?OZM+}sXS*dMaw^wAKL5odii0L_Eme$Uf|pU2hs8aPQA3( z%FoJ=M*JZ26jCzMU~ogVFc0hvd$k6{{*7h=5<9&ivldWn4(#n-@yuS&PN{&%FhZoGn;tRzjUnPq?BT%^Y;(M){~p zmQswwww(~VsyBr!HytlgaaPqa1t$stjZzaT889lfPUJ1wDH)w{2IrCKh)RPp9y>C zGpYZi4Wg0XP1;bEHdLhzRcS-0&^8kO4K43kmv#ysCy)+i(k-$b_Vh(OnGym|A|CVI zgq!&`Z*iCh=m&IEnLBX6O}GOGnPxp#%G{A&XB{t?3ZK+THa|VHYiPK+h~NquCl(>M z?N~^&jH>A6KbRq>07Dp|E@CXe5&kRsgfm|D1bf{-1o!#T z=|_VkNfbvb|MDEgr|zZ<6G!68#x-=_TtQ?RJ2&NAkzOzByVnV+BI!m9lTM^L%C?RP Wn0y8alf`#1nBGN>0~}xC@AAKQD3Lh; literal 0 HcmV?d00001 diff --git a/src/DepositCalculator.java b/src/DepositCalculator.java new file mode 100644 index 00000000..074b5975 --- /dev/null +++ b/src/DepositCalculator.java @@ -0,0 +1,39 @@ +import java.util.Scanner; + +public class DepositCalculator { + double findComplexPercent(double amount, double yearRate, int depositPeriod) { + double totalAmount = amount * Math.pow((1 + yearRate / 12), 12 * depositPeriod); + return getRounded(totalAmount, 2); + } + + double findSimplePercent(double amount, double yearRate, int depositPeriod) { + double totalAmount = amount + amount * yearRate * depositPeriod; + return getRounded(totalAmount, 2); + } + + double getRounded(double value, int places) { + double scale = Math.pow(10, places); + return Math.round(value * scale) / scale; + } + + void getResultDeposit( ) { + Scanner scanner = new Scanner(System.in); + System.out.println("Введите сумму вклада в рублях:"); + int amount = scanner.nextInt(); + System.out.println("Введите срок вклада в годах:"); + int period = scanner.nextInt( ); + System.out.println("Выберите тип вклада, 1 - вклад с обычным процентом, 2 - вклад с капитализацией:"); + int userInput = scanner.nextInt(); + double result = 0; + if (userInput == 1) { + result = findSimplePercent(amount, 0.06, period); + } else if (userInput == 2) { + result = findComplexPercent(amount, 0.06, period); + } + System.out.println("Результат вклада: " + amount + " за " + period + " лет превратятся в " + result); + } + + public static void main(String[] args) { + new DepositCalculator().getResultDeposit(); + } +} 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(); -} - - - - -} From 9f09ff24b6333f65ef002bafeb215a77bcec8326 Mon Sep 17 00:00:00 2001 From: babkaizergil <118020159+babkaizergil@users.noreply.github.com> Date: Mon, 12 Dec 2022 17:03:23 +0400 Subject: [PATCH 2/2] Update DepositCalculator.java --- src/DepositCalculator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DepositCalculator.java b/src/DepositCalculator.java index 074b5975..40e48a38 100644 --- a/src/DepositCalculator.java +++ b/src/DepositCalculator.java @@ -16,12 +16,12 @@ public class DepositCalculator { return Math.round(value * scale) / scale; } - void getResultDeposit( ) { + void getResultDeposit() { Scanner scanner = new Scanner(System.in); System.out.println("Введите сумму вклада в рублях:"); int amount = scanner.nextInt(); System.out.println("Введите срок вклада в годах:"); - int period = scanner.nextInt( ); + int period = scanner.nextInt(); System.out.println("Выберите тип вклада, 1 - вклад с обычным процентом, 2 - вклад с капитализацией:"); int userInput = scanner.nextInt(); double result = 0;