자바_기초
자바기초)Variable 연습문제
잠수콩
2019. 5. 14. 08:37
public class Practice {
public static void main(String[] args) {
// 연습 - 라면값 지불후 잔돈 500, 100 짜리 갯수 구하기
int myMoney = 10000; //가진돈
int ramyun = 1300; //라면값
int ea500 = 500; //거스름돈 500원 단위
int ea100 = 100; //거스름돈 100원 단위
int myLeftMoney = 0; //거스름돈 변수
int myLeftMoney500 = 0; //거스름돈 중 500원 단위 갯수
int myLeftMoney100 = 0; //거스름돈 중 100원 단위 갯수
myLeftMoney = myMoney - ramyun;
myLeftMoney500 = myLeftMoney / ea500;
myLeftMoney100 = (myLeftMoney - (myLeftMoney500 * ea500)) / ea100;
System.out.println("거스름돈 : " + myLeftMoney);
System.out.println("500원 개수 : " + myLeftMoney500);
System.out.println("100원 개수 : " + myLeftMoney100);
}
}