*자바에서는 한글도 식별자로 사용가능하다
import java.util.Scanner;
public class ex3 {
public static void main(String[] args) {
// TODO Auto-generated method stub
//돈의 액수를 상수로 선언
final int 오만원 = 50000;
final int 만원 = 10000;
final int 천원 = 1000;
final int 백원 = 100;
final int 오십원 = 50;
final int 십원 = 10;
final int 일원 = 1;
Scanner sc = new Scanner(System.in);
System.out.print("금액을 입력하십시오>>");
int money = sc.nextInt();
int cnt = money/오만원;
int res = money%오만원;
if(cnt>0) System.out.println("오만원권 "+cnt+"매");
cnt = res/만원;
res = money%만원;
if(cnt>0) System.out.println("만원권 "+cnt+"매");
cnt = res/천원;
res = money%천원;
if(cnt>0) System.out.println("천원권 "+cnt+"매");
cnt = res/백원;
res = money%백원;
if(cnt>0) System.out.println("백원 "+cnt+"개");
cnt = res/오십원;
res = money%오십원;
if(cnt>0) System.out.println("오십원 "+cnt+"개");
cnt = res/십원;
res = money%십원;
if(cnt>0) System.out.println("십원 "+cnt+"개");
cnt = res/일원;
res = money%일원;
if(cnt>0) System.out.println("일원 "+cnt+"개");
sc.close();
}
}'명품JAVA프로그래밍 > 2장 자바 기본 프로그래밍' 카테고리의 다른 글
| [명품JAVA프로그래밍] 2장 실습문제 5번 (0) | 2021.12.15 |
|---|---|
| [명품JAVA프로그래밍] 2장 실습문제 4번 (0) | 2021.12.15 |
| [명품JAVA프로그래밍] 2장 실습문제 2번 (0) | 2021.12.14 |
| [명품JAVA프로그래밍] 2장 실습문제 1번 (0) | 2021.12.14 |
| [명품JAVA프로그래밍] 2장 Open Challenge (0) | 2021.12.14 |