Last active
August 29, 2015 14:10
-
-
Save takanakahiko/758424f129b7fa81158a to your computer and use it in GitHub Desktop.
円をドルに変えるやつ
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
public class Ryougae{ | |
public static void main(String[] args){ | |
int en = Integer.parseInt(System.console().readLine("日本円=")); | |
if(en<117){ | |
System.out.println("換算できないよ!"); | |
return; | |
} | |
int doller = en / 117; | |
en %= 117; | |
String text = ""; | |
int tanni[] = {100,50,20,10,5,1}; | |
for(int i = 0; i < tanni.length; i++){ | |
if(doller/tanni[i]>=1){ | |
text += tanni[i]+"ドルが"+(doller/tanni[i])+"\n"; | |
doller %= tanni[i]; | |
} | |
} | |
if(en==0) | |
text += "おつりは無し"; | |
else | |
text += "おつりは"+en+"円"; | |
System.out.println(text); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment