admin管理员组

文章数量:1558101

*2.22(金融应用:货币单位)改写程序清单2-10,解决将double型值转换为int型值可能会造成精度损失问题。以整数值作为输入,其最后两位代表的是美分币值。例如:1156就表示的是11美元56美分。

*2.22(Financial application: monetary units) Rewrite Listing 2.10, ComputeChange. java, to fix the possible loss of accuracy when converting a double value to an int value. Enter the input as an integer whose last two digits represent the cents. For example, the input 1156 represents 11 dollars and 56 cents.

下面是参考答案代码:

import java.util.*;

public class MonetaryUnitsQuestion22 {
   
	public static void main(String[] args

本文标签: 第二章货币单位金融Units