Skip to content
Open
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
63 changes: 32 additions & 31 deletions src/calculate_deposit.java
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
import java.net.URI;import java.util.Scanner;import java.io.IOException;
import java.util.Scanner;

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; }
public class calculate_deposit {
double calculateComplexPercent(double a, double y,int d ) { // Привет, тут ты, наверное забыл пробел после запятой!))
double pay = a * Math.pow((1 + y / 12), 12 * d);
return rnd(pay, 2);// А тут в твой программе закралась не понятная переменная, было бы круто назвать ее по-другому
}
double calculateSimplePercent(double doubleAmount,double doubleYearRate, int depositPeriod) { // Тот же недочет, что и вперый раз
return rnd(doubleAmount + doubleAmount * doubleYearRate * depositPeriod, 2); // Переменную лучше назвать round
}
double rnd(double value, int places) { // лучше назвать round
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("Введите срок вклада в годах:") ;
void doImportantJob( ) {
int period;
int action;
Scanner abcdef = new Scanner(System.in); // Scanner scanner будет выглядеть лучше
System.out.println("Введите сумму вклада в рублях:") ;

int amount = abcdef.nextInt();
// лучше соеденить это пробелом
System.out.println("Введите срок вклада в годах:") ;
period = abcdef.nextInt( );
System.out.println ( "Выберите тип вклада, 1 - вклад с обычным процентом, 2 - вклад с капитализацией:");
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); }

if (action ==1) outDoubleVar = calculateSimplePercent(amount, 0.06, period);
else if (action == 2) {
outDoubleVar = calculateComplexPercent(amount, 0.06, period);
}
System.out.println("Результат вклада: " + amount + " за " + period + " лет превратятся в " + outDoubleVar);
}
public static void main(String[] args)
{
new calculate_deposit().do_important_job();
}




public static void main(String[] args) { // мейн лучше перенести в начало класса
new calculate_deposit().doImportantJob();
}
}