Skip to content

Instantly share code, notes, and snippets.

@takanakahiko
Last active August 29, 2015 14:10
Show Gist options
  • Save takanakahiko/758424f129b7fa81158a to your computer and use it in GitHub Desktop.
Save takanakahiko/758424f129b7fa81158a to your computer and use it in GitHub Desktop.
円をドルに変えるやつ
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