Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

исправленный Code style #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
43 changes: 43 additions & 0 deletions src/CalculateDeposit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import java.util.Scanner;

public class CalculateDeposit {

double calculateComplexPercent(double money, double yearRate, int period) {
double amountOfFunds = money * Math.pow((1 + yearRate / 12), 12 * period);
return accrualOfInterest(amountOfFunds, 2);
}

double calculateSimplePercent(double money, double yearRate, int period) {
return accrualOfInterest(money + money * yearRate * period, 2);
}

double accrualOfInterest(double sum, int bet) {
Copy link
Author

Choose a reason for hiding this comment

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

мне кажется лучше иначе назвать метод и переменную bet. Этот метод нужен, чтобы отобразить заданное количество знаков после запятой, в данном случае 2.

double percent = Math.pow(10, bet);
return Math.round(sum * percent) / percent;
}

void calculateСontribution( ) {
Copy link
Author

Choose a reason for hiding this comment

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

Лишний пробел в скобках

int period;
int action;
double sumContributor = 0;

Scanner scanner = new Scanner(System.in);
System.out.println("Введите сумму вклада в рублях:");
int money = scanner.nextInt();
System.out.println("Введите срок вклада в годах:");
period = scanner.nextInt( );
System.out.println("Выберите тип вклада, 1 - вклад с обычным процентом, 2 - вклад с капитализацией:");
action = scanner.nextInt();

if (action == 1) {
sumContributor = calculateSimplePercent(money, 0.06, period);
} else if (action == 2) {
sumContributor = calculateComplexPercent(money, 0.06, period);
}
System.out.println("Результат вклада: " + money + " за " + period + " лет превратятся в " + sumContributor);
}

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

This file was deleted.