Created
December 8, 2014 10:01
-
-
Save d-kanazawa/cbfc3c78e265e4401610 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
* プログラム名 Ryogae.java | |
* プログラムの内容の説明 日本円(¥)を入力し,その金額を米ドル(US$)に両替するプログラム | |
* 作成日 12/1 | |
*/ | |
public class Ryogae { | |
public static void main(String[] args) { | |
String line1 = System.console().readLine("金額(日本円)="); | |
int n=Integer.parseInt(line1); | |
int i; //ドル変換 | |
int m; //お釣り | |
if(n<117){ | |
System.out.println("両替できません"); | |
}else{ | |
i=n/117; | |
m=n%117; | |
n=n/117; | |
n=n*117; | |
int a =n; | |
System.out.println("両替できる日本円は"+ n +"円で、ドルに換算すると"+ i +"ドルです。"); | |
if(n>=11700){ | |
a=n/11700; | |
System.out.println("100ドル紙幣"+a+"枚"); | |
} | |
if(n%11700>=5850){ | |
System.out.println("50ドル紙幣を"+a+"枚"); | |
} | |
if(n>5850&&n>11700){ | |
a=n/5850; | |
System.out.println("50ドル紙幣を"+a+"枚"); | |
} | |
if(n>=2340&&n<5850){ | |
a=n/2340; | |
System.out.println("20ドル紙幣を"+a+"枚"); | |
} | |
if(n>=1170 && n<2340){ | |
a=n%2340/1170; | |
System.out.println("10ドル紙幣を"+a+"枚"); | |
} | |
if(n>=585 && n<1170 ){ | |
a=n%1170/585; | |
System.out.println("5ドル紙幣を"+a+"枚"); | |
} | |
if(n<585){ | |
a=n%117; | |
System.out.println("1ドル紙幣を"+a+"枚"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment