Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
You can’t perform that action at this time.