Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

463 changes: 463 additions & 0 deletions .idea/dbnavigator.xml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions m1-t12-code-style.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
47 changes: 47 additions & 0 deletions src/DepositCalculator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import java.util.Scanner;

public class DepositCalculator {

private double calculateComplexPercent(double amount, double annualRate, int depositPeriod) {
double pay = amount * Math.pow((1 + annualRate / 12), 12 * depositPeriod);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Привет! 1 отступ = 4 пробела. Почему-то мне кажется, что последующая строка должна быть с отступом 8 пробелов. Но может я ошибаюсь и это используется только при переносе на новую строку?
Здесь 7 пробелов

return roundNumber(pay, 2);
}

private double calculateSimplePercent(double amount, double annualRate, int depositPeriod) {
return roundNumber(amount + amount * annualRate * depositPeriod, 2);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а здесь 8 пробелов

}

private double roundNumber(double value, int places) {
double scale = Math.pow(10, places);
return Math.round(value * scale) / scale;
}

public void calculateDepositValue() {
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 resultAmount = 0;

if (action == 1) {
resultAmount = calculateSimplePercent(amount, 0.06, period);
} else if (action == 2) {
resultAmount = calculateComplexPercent(amount, 0.06, period);
}

System.out.println("Результат вклада: " + amount + " за " + period + " лет превратятся в " + resultAmount);
}

public static void main(String[] args) {
new DepositCalculator().calculateDepositValue();
}
}
40 changes: 0 additions & 40 deletions src/calculate_deposit.java

This file was deleted.