- /*
- * Quiz6
- *
- * RMB找零问题,要求精确到圆,角,分
- *
- * 2008年12月13日
- *
- *(Cason_xu)
- */
- import java.util.Scanner;
- class Quiz6 {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- System.out.print("请输入您要兑换的RMB的值:");
- double n = keyboard.nextDouble( );
- int m = (int)(100 * n);
- double[] mo = {100,50,20,10,5,2, 1,0.5,0.2,0.1,0.01};
- int[] mon = {10000,5000,2000,1000,500,200, 100,50,20,10,1};
- int[] cash = new int[11];
- int i = 0 ;
- while (m > 0 ) {
- cash[i] = m / mon[i];
- m = m -mon[i] * cash[i];
- if (cash[i] != 0) {
- System.out.println(mo[i] + "/t" + "元:" + "/t" + cash[i] + "张");
- }
- i++;
- }
- }
- }
[Java]RMB找零问题,要求精确到圆,角,分
最新推荐文章于 2022-06-17 12:36:04 发布