Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 맥북 데이터베이스 설치
- 자바연산자
- Mac Sqlplus
- 자바변수
- mac oracle
- 자바거스름돈
- 자바 거스름돈구하기
- 맥 sql설치
- 맥북 데이터베이스
- 자바연산
- 자바 커피
- javareview
- java
- 자바계산
- 맥 데이터베이스
- 자바
- 맥os 데이터베이스
- 자바 공부
- 자바공부
- 자바 복습
- 맥북 개발
- 자바복습
- java거스름돈구하기
- 자바실수
- Mac db
- 자바연산자사용
- 맥 오라클
Archives
- Today
- Total
DevTagebuch
거스름돈 구하기_2 본문
키보드로 원하는 커피의 값과 투입하려는 금액을 입력하고 거스름돈 구하기.
import java.util.Scanner;
public class Problem04_03 {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int coffee, money, change;
System.out.print("얼마짜리 커피를 드시겠어요? ==>");
coffee=s.nextInt();
System.out.print("금액을 투입해주세요. ==>");
money=s.nextInt();
change=money-coffee;
System.out.printf("거스름 돈은 %d원 입니다.",change);
int c500,c100,c50;
c500=change/500;
change=change%500;
c100=change/100;
change=change%100;
c50=change/50;
change=change%50;
System.out.println();
System.out.printf("500원 짜리 %d개\n",c500);
System.out.printf("100원 짜리 %d개\n",c100);
System.out.printf("50원 짜리 %d개\n",c50);
}
}
'Java > Do it' 카테고리의 다른 글
거스름돈 구하기_1 (0) | 2020.04.19 |
---|---|
두 실수의 연산 (0) | 2020.04.19 |
for 문 사용하여 입력된 문자열 거꾸로 출력하기 (0) | 2020.04.18 |
기본 자바형 크기 구하기 (0) | 2020.04.18 |
원하는 진수변환과 값 입력 후 출력 (Scanner, If) (0) | 2020.04.18 |
Comments