Create a gist now

Instantly share code, notes, and snippets.

Rozwiązanie zadania z #main z 24 października 2016
public class CoffeePriceCalculator {
public double getFinalPrice(double cofeePrice, int taxPercents, int tipPercents) {
long roundedAmountInGrosze = Math.round(cofeePrice*(100 + taxPercents + tipPercents));
return roundedAmountInGrosze/100.0;
}
}
import java.math.BigDecimal;
import java.math.RoundingMode;
public class CofeePriceCalculator {
public BigDecimal getFinalPrice(BigDecimal cofeePrice, int taxPercents, int tipPercents) {
BigDecimal amountInGrosze = cofeePrice.multiply(BigDecimal.valueOf(100 + taxPercents + tipPercents));
BigDecimal result = amountInGrosze.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment