File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ public class BonusService {
2+ public long calculate (long amount , boolean registered ) {
3+ int percent = registered ? 3 : 1 ;
4+ long bonus = amount * percent / 100 / 100 ;
5+ long limit = 500 ;
6+ if (bonus > limit ) {
7+ bonus = limit ;
8+ }
9+ return bonus ;
10+ }
11+ }
12+
13+
Original file line number Diff line number Diff line change 1+ public class Main {
2+ public static void main (String [] args ) {
3+ BonusService service = new BonusService ();
4+
5+ long bonusBelowLimitForRegistered = service .calculate (1000_60 , true );
6+ System .out .println (bonusBelowLimitForRegistered );
7+
8+ long bonusOverLimitForRegistered = service .calculate (1_000_000_60 , true );
9+ System .out .println (bonusOverLimitForRegistered );
10+
11+ long bonusBelowLimitForUnRegistered = service .calculate (1000_60 , false );
12+ System .out .println (bonusBelowLimitForUnRegistered );
13+
14+ long bonusOverLimitForUnRegistered = service .calculate (1_000_000_60 , true );
15+ System .out .println (bonusOverLimitForUnRegistered );
16+ }
17+ }
18+
You can’t perform that action at this time.
0 commit comments