Created
December 8, 2014 10:01
-
-
Save yukarin0001/7d3107e2e62d925a24df 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
/* | |
* プログラム名 両替 | |
* プログラムの内容の説明 円をドルに両替するプログラム | |
* 作成日 12/1 | |
*/ | |
import java.io.*; | |
public class Ryogae { | |
public static void main(String[] args) { | |
String line = System.console().readLine("金額(日本円)="); | |
int x = Integer.parseInt(line); | |
int y = x / 117; | |
int z = x % 117; | |
if (x < 117) { | |
System.out.println("両替できません"); | |
} else if (x % 117 == 0) { | |
System.out.println("両替できる日本円は"+x+"円で、ドル換算すると"+y+"ドルです。"); | |
int doru100 = y / 100; | |
y=y%100; | |
int doru50 = y / 50; | |
y=y%50; | |
int doru20 = y / 20; | |
y=y%20; | |
int doru10 = y / 10; | |
y=y%10; | |
int doru5 = y / 5; | |
y=y%5; | |
int doru1 = y / 1; | |
if (doru100 != 0) | |
System.out.println("100ドル紙幣"+doru100+"枚"); | |
if (doru50 != 0) | |
System.out.println("50ドル紙幣"+doru50+"枚"); | |
if (doru20 != 0) | |
System.out.println("20ドル紙幣"+doru20+"枚"); | |
if (doru10 != 0) | |
System.out.println("10ドル紙幣"+doru10+"枚"); | |
if (doru5 != 0) | |
System.out.println("5ドル紙幣"+doru5+"枚"); | |
if (doru1 != 0) | |
System.out.println("1ドル紙幣"+doru1+"枚"); | |
System.out.println("お釣りはありません"); | |
} else if (x / 117 != 0 ){ | |
System.out.println("両替できる日本円は"+x+"円で、ドル換算すると"+y+"ドルです。"); | |
int doru100 = y / 100; | |
y=y%100; | |
int doru50 = y / 50; | |
y=y%50; | |
int doru20 = y / 20; | |
y=y%20; | |
int doru10 = y / 10; | |
y=y%10; | |
int doru5 = y / 5; | |
y=y%5; | |
int doru1 = y / 1; | |
if (doru100 != 0) | |
System.out.println("100ドル紙幣"+doru100+"枚"); | |
if (doru50 != 0) | |
System.out.println("50ドル紙幣"+doru50+"枚"); | |
if (doru20 != 0) | |
System.out.println("20ドル紙幣"+doru20+"枚"); | |
if (doru10 != 0) | |
System.out.println("10ドル紙幣"+doru10+"枚"); | |
if (doru5 != 0) | |
System.out.println("5ドル紙幣"+doru5+"枚"); | |
if (doru1 != 0) | |
System.out.println("1ドル紙幣"+doru1+"枚"); | |
System.out.println("お釣りは"+z+"円です"); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment