Created
May 31, 2020 08:13
-
-
Save jung-yun/517eca3e6ba566a71fb7b0d7cca88527 to your computer and use it in GitHub Desktop.
java practice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.practice; | |
import java.util.Scanner; | |
public class Day3_3_exercise { | |
public static void main (String[] args) { | |
int money = 10000, price = 2730; | |
int FiveThousandWon = (money-price)/5000; | |
int n1 = (money-price)%5000; | |
int ThousandWon = n1/1000; | |
int n2 = n1%1000; | |
int HundredWon = n2/100; | |
int n3 = n2%100; | |
int TenWon = n3/10; | |
System.out.printf("5천원 짜리 %d 장", FiveThousandWon); | |
System.out.printf("천원짜리 %d 장", ThousandWon); | |
System.out.printf("백원짜리 %d 개", HundredWon); | |
System.out.printf("십원짜리 %d 개\n", TenWon); | |
Scanner scan = new Scanner(System.in); | |
int ticket; | |
System.out.println("티켓번호를 입력하세요 (4자리): "); | |
ticket = scan.nextInt(); | |
if(ticket/1000<1 || ticket/1000 >= 10) { | |
System.out.println("4자리 수를 입력"); | |
}else if(ticket%10==1) { | |
System.out.println("서울"); | |
}else if(ticket%10==2) { | |
System.out.println("대전"); | |
}else if(ticket%10==3) { | |
System.out.println("대구"); | |
}else if(ticket%10==4) { | |
System.out.println("부산"); | |
}else if(ticket%10==5) { | |
System.out.println("광주"); | |
}else | |
System.out.println("대한민국"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment