Programmers
코딩테스트 연습 - 위클리첼린지 1주차 부족한금액계산하기
Developer Garam.Choi
2021. 8. 29. 13:52
@org.junit.Test
public void price_return_test1(){
int price = 3;
int money = 20;
int count = 4;
long answer = -1;
long castingTotalPrice = (long)price;
for(int i=2; i <= count; i++){
castingTotalPrice += price * i;
}
if(castingTotalPrice > money){
answer = castingTotalPrice-money;
}else {
answer = 0;
}
System.out.println(answer);
}