Skip to content

Instantly share code, notes, and snippets.

@moonjonggwan
Created March 19, 2024 03:25
Show Gist options
  • Save moonjonggwan/2976ec6b0c22d0768a0c5f45faf344d2 to your computer and use it in GitHub Desktop.
Save moonjonggwan/2976ec6b0c22d0768a0c5f45faf344d2 to your computer and use it in GitHub Desktop.
package homework;
/* 문종관 */
import java.util.Scanner;
public class Mini2 {
public static int cashBack (int price) {
if (price >= 3000) {
return 300;
}
return (int)Math.floor(price / 1000) * 100;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("[캐시백 계산]");
System.out.print("결제 금액을 입력해 주세요. (금액) : ");
int price = sc.nextInt();
if (price < 0) {
System.out.println("금액은 0원 이상 이어야 합니다.");
} else {
System.out.printf("결제 금액은 %d이고, 캐시백은 %d원 입니다.", price, cashBack(price));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment