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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/m1-t12-code-style.iml
40 changes: 40 additions & 0 deletions src/DepositCalculator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import java.util.Scanner;

public class DepositCalculator {

public static void main(String[] args) {
new DepositCalculator().findInputValue();
}

double calculateComplexPercent(double a, double y, int d) {
double pay = a * Math.pow((1 + y / 12), 12 * d);
return findRoundValue(pay, 2);
}

double calculateSimplePercent(double amount, double yearRate, int depositPeriod) {
return findRoundValue(amount + amount * yearRate * depositPeriod, 2);
}

double findRoundValue(double base, int exponent) {
double pow = Math.pow(10, exponent);
return Math.round(base * pow) / pow;
}

void findInputValue() {
Scanner input = new Scanner(System.in);
System.out.println("Введите сумму вклада в рублях:");
int amount = input.nextInt();
System.out.println("Введите срок вклада в годах:");
int period = input.nextInt();
System.out.println("Выберите тип вклада, 1 - вклад с обычным процентом, 2 - вклад с капитализацией:");
int action = input.nextInt();
double result = 0;
if (action == 1) {
result = calculateSimplePercent(amount, 0.06, period);
} else if (action == 2) {
result = calculateComplexPercent(amount, 0.06, period);
}
System.out.println("Результат вклада: " + amount + " за " + period + " лет превратятся в " + result);
}

}
40 changes: 0 additions & 40 deletions src/calculate_deposit.java

This file was deleted.