-
-
Save jderda/2f451db734e8cfacaaa12c1094b8e3b1 to your computer and use it in GitHub Desktop.
Rozwiązanie zadania z #main z 24 października 2016
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CoffeePriceCalculator { | |
public double getFinalPrice(double cofeePrice, int taxPercents, int tipPercents) { | |
long roundedAmountInGrosze = Math.round(cofeePrice*(100 + taxPercents + tipPercents)); | |
return roundedAmountInGrosze/100.0; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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