Skip to content

Commit

Permalink
done all but last task of module3
Browse files Browse the repository at this point in the history
  • Loading branch information
snychka committed May 20, 2020
1 parent 4158e6a commit c8f2f16
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/main/java/com/h2/SavingsCalculator.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,59 @@
package com.h2;

import java.time.LocalDate;
import java.time.YearMonth;

public class SavingsCalculator {
private final float[] credits;
private final float[] debits;

public SavingsCalculator(float[] credits, float[] debits) {
this.credits = credits;
this.debits = debits;
}

public float calculate() {
return sumOfCredits() - sumOfDebits();
}

private float sumOfCredits() {
float sum = 0.0f;
for (float credit : credits) {
sum += credit;
}
return sum;
}

private float sumOfDebits() {
float sum = 0.0f;
for (float debit : debits) {
sum += debit;
}
return sum;
}

private static int remainingDaysInMonth(LocalDate d) {
YearMonth yearMonth = YearMonth.of(d.getYear(), d.getMonth());
int totalDaysInMonth = yearMonth.lengthOfMonth();
return totalDaysInMonth - d.getDayOfMonth();

}

public static void main(String[] args) {


final String[] creditsAsString = args[0].split(",");
final String[] debitsAsString = args[1].split(",");

final float[] credits = new float[creditsAsString.length];
final float[] debits = new float[debitsAsString.length];

for (int i = 0; i < creditsAsString.length; i++) {
credits[i] = Float.parseFloat(creditsAsString[i]);
}

for (int i = 0; i < debitsAsString.length; i++) {
debits[i] = Float.parseFloat(debitsAsString[i]);
}
}
}

0 comments on commit c8f2f16

Please sign in to comment.